多条记录合并

关键点 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

    原文作者:张一一
    原文地址: https://www.jianshu.com/p/facb8827fee3
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞