Click here to Skip to main content
15,740,826 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I have table like

Id     GroupName
---    --------
1      science
2      science
3      science
4      arts
5      arts
6      commerce

I need to write a query to get an output like this

Id     GroupName
---    --------
1,2,3      science
4,5        arts
6          commerce

Please help me resolve this

1 solution

Seems like a homework. You can start from here MySQL : Multiple row as comma separated single row[^]
Share this answer
Maciej Los 29-May-15 9:07am    
_Asif_ 29-May-15 13:12pm    
Thanks Maciej
Swathi Nagaraj 1-Jun-15 7:56am    
Thanks Asif

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900