Edit

group_concat

Description

This is an aggregate function similar to sum(). group_concat concatenates the data from multiple rows into one string, with the second argument sep being the separator. The second argument can also be omitted. This function usually needs to be used along with group by statement.

Please note that the multiple data may not be concatenated in sequence because it uses distributed computing.

Syntax

VARCHAR group_concat(VARCHAR str[, VARCHAR sep])

Examples

MySQL > select value from test;
+-------+
| value |
+-------+
| a     |
| b     |
| c     |
+-------+

MySQL > select group_concat(value) from test;
+-----------------------+
| group_concat(`value`) |
+-----------------------+
| a, b, c               |
+-----------------------+

MySQL > select group_concat(value, " ") from test;
+----------------------------+
| group_concat(`value`, ' ') |
+----------------------------+
| a b c                      |
+----------------------------+

keyword

GROUP_CONCAT,GROUP,CONCAT