多对多表联合查询重复问题

用户和角色表多对多关系

select a.*,GROUP_CONCAT(c.id) as roles from tb_users a,tb_users_roles b,tb_roles c where a.id=b.user_id and b.role_id=c.id and b.role_id in (1,40) group by a.id
原文地址:https://www.cnblogs.com/cherylgi/p/15514816.html