Divakarcool Divakarcool - 2 months ago 7
MySQL Question

I am unable fecthing the data from table in mysql

I have a table suppose

users


Name Age
------ -------

ABC 20
XYZ 20
PQR 17
EFG 56
LPQ 17


I want Like This :-

Age Name
---- ------
20 ABC,XYZ
56 EFG
17 PQR,LPQ


please help me to solve this problem i will very thankful of you .

Answer

just use GROUP_CONCAT(Name) Docs GROUP_CONCAT

SELECT Age,GROUP_CONCAT(Name) as Name FROM table GROUP BY Age;