Using Group Concat
GROUP_CONCAT allows to concatenate a group of strings correspoding to different rows in a table, agregated together by the GROUP BY clause.
Examples
SELECT GROUP_CONCAT(code SEPARATOR ' ') FROM t1 GROUP BY country
The SEPARATOR clause is optional.
Tips
The configuration variable group_concat_max_len limits the size, in bytes, of the GROUP_CONCAT function. This defaults to 8192 bytes. It is important to modify this value to fits your need, because if a bigger result is produced by a query, it will be sinlently chopped if it is needed.
