GROUP_CONCAT() function is used to concatenate column values into a single string. It is very useful if you would otherwise perform a lookup of many row and then concatenate them on the client end.
For example if you query:
mysql> SELECT Language FROM CountryLanguage WHERE CountryCode
= 'THA';
It outputs:
Language |
Chinese |
Khmer |
Kuy |
Lao |
To concatenate the values into a single string, you query:
mysql> SELECT GROUP_CONCAT(Language) As Languages FROM
CountryLanguage WHERE CountryCode = 'THA';
Then the output will be:
Languages |
Chinese, Khmer, Kuy, Lao … |