MySQL Group Concat Function

The group_concat() function in MySQL is really nifty. It concatenates all rows that match your group by statement into a single, comma separated string.

Essentially, it transposes rows to columns.

Take this example. Say you have a table that stores a set of locations by country, state and city.