mysql合并相同字段,不同的拼接在起后
要把相同的数据合并了,后面name累加,效果如下:
代码如下:
select us.id ID,us.uname 账号,mg.groupname 所在组,mg.groupnote 描述,group_concat(distinct m.title separator ';') 拥有权限 from users as us LEFT JOIN menugroup as mg on us.menu=mg.id LEFT JOIN group_menu as gm on mg.id=gm.group_id LEFT JOIN menu as m on gm.menu_id=m.id GROUP BY id ORDER BY id,us.uname,title
需要叠加的字段用函数group_comcat(需要叠加的字段) 即可
参考地址:
http://blog.csdn.net/wwwyuanliang10000/article/details/27536175