Reputation: 14902
I have a query that returns several rows that I'd like to group by a column. So for example,
title | label
--------------
may ny
may ct
june ma
june ri
How would I (efficiently) return
title | label
--------------
may ct,ny
june ma,ri
such that the ordering of the concatenation is alphabetical?
Upvotes: 1
Views: 21
Reputation: 43494
Check the GROUP_CONCAT
function. The query would be:
SELECT title, GROUP_CONCAT(label ORDER BY label)
GROUP BY title
Upvotes: 2