多条记录合并
2015-03-31 本文已影响19人
张一一
关键点 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