GROUP_CONCAT

GROUP_CONCAT takes string values and aggregates them into one value for each row with an optional separator.

ParameterTypeDescription
value
string
the values to be concatenated
Returns: string

Example

query:

SELECT GROUP_CONCAT(manager)
  FROM sales_teams

result:

manager
Rocco Neubert Celia Rouche Summer Sewald Summer Sewald Celia Rouche Melvin Marxen Melvin Marxen Summer Sewald Dustin Brinkmann Melvin Marxen Melvin Marxen Rocco Neubert Summer Sewald Melvin Marxen Rocco Neubert Cara Losch Celia Rouche Cara Losch Celia Rouche Rocco Neubert Dustin Brinkmann Cara Losch Rocco Neubert Cara Losch Dustin Brinkmann Cara Losch Summer Sewald Celia Rouche Dustin Brinkmann Dustin Brinkmann

query:

SELECT GROUP_CONCAT(DISTINCT manager SEPARATOR ", ") AS Managers
  FROM sales_teams

And the result would be:

Managers
Rocco Neubert, Celia Rouche, Summer Sewald, Melvin Marxen, Dustin Brinkmann, Cara Losch