mysql group_concat code example

Example 1: mysql group_concat distinct

SELECT GROUP_CONCAT(DISTINCT categories ORDER BY categories ASC SEPARATOR ' ') FROM table

Example 2: group by mysql and concatenate string

mysql> select Id,group_concat(Name SEPARATOR ',') as GroupConcatDemo from GroupConcatenateDemo
   -> group by Id;

Example 3: how to use group_concat in sql server

SELECT STRING_AGG(column_name, ',') AS Result
FROM table_name

Example 4: group_concat mysql

GROUP_CONCAT(expr);

Example 5: group_concat in mysql

GROUP_CONCAT(eng_category_name SEPARATOR ',') as eng_category_name

Example 6: mysql group concat

/* By deafult separe itens by "," */
group_concat(p.nameItem) as listProdItem
/* Used <br> to list itens one below the other in HTML page */
group_concat(p.nameItem separator '<br>') as listProdItem