Ad space (banner)
🗄️SQL Lessons
Lesson 48 / 50

Merging Grouped Values with GROUP_CONCAT

This lesson covers merging values within a group into one string using GROUP_CONCAT. It's for anyone searching "SQL GROUP_CONCAT tutorial."

GROUP_CONCAT(column) is an aggregate function that joins every value within a GROUP BY group into one comma-separated string — handy for something like "list every student's name, per class."

The example uses GROUP_CONCAT(name) to merge the names of students sharing a class into a single, comma-separated string. A plain GROUP BY would normally spread that list across multiple rows — see how it collapses down to just one, easy-to-read row.

A common early mistake is not knowing you can change the separator — passing a second argument, like GROUP_CONCAT(name, '; '), swaps in a different separator than the default comma. Turning what would otherwise be several rows into a single readable string is exactly what this function is for, and being able to customize the separator makes it especially useful for report output and on-screen formatting.

SQL
OUTPUT

💡 The SQL engine may take a few seconds to load the first time you run code.

Ad space (banner)
Ad space (in-article)