多条记录合并

关键点 group by 和 group_concat()

eg

id city people

1 Hangzhou Tom

1 Hangzhou Jack

3 Guangzhou Mary


select id ,city,group_concat(people) as people

from city

group by id;

id city people

output

1 Hangzhou Tom,Jack

3 Guangzhou Mary

你可能感兴趣的:(多条记录合并)