|
|||||||
| SQL For all Structured Query Language, and general database questions. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Hold it! Turns out there is an aggregate function to do exactly that: GROUP_CONCAT. I could swear I've searched up and down for this before; how did I not know?
Oh well, perhaps I'll save someone else the trouble: SELECT p.name, GROUP_CONCAT(h.hobby SEPARATOR ", ") AS hobbies FROM people p LEFT JOIN people_hobbies h ON p.personId=h.personId GROUP BY p.personID ORDER BY p.name |
![]() |
| Bookmarks |
| Tags |
| aggregate, foreign, sql |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|