赞
踩
a表:
b表:
需求:a表role关联B表查询出角色名称并用逗号隔开
SELECT a.id, a.NAME, GROUP_CONCAT(b.NAME) AS roleFROM USER aINNER JOIN role b ON FIND_IN_SET(b.id, a.role)GROUP BY a.id
查询结果如下: