GROUP_CONCAT()
GROUP_CONCAT(name) glues names in a group into one string. SELECT city, GROUP_CONCAT(name ORDER BY name SEPARATOR ', ') FROM students GROUP BY city;
group_concat_max_len truncates long lists (default 1024). Raise it in session if you must, or don’t use GROUP_CONCAT as a data dump.
Trap — GROUP_CONCAT as a substitute for a proper child table in the app.
On the example next to this theory: GROUP_CONCAT(): create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.
Exam tip
GROUP_CONCAT(name SEPARATOR ', ') per city.