现在有这样的两个表
A表:

B表

我现在要查询A表中的id,name和B表中的cname
解决方法:
select user.id,user.name,GROUP_CONCAT(role.role_name) as b_name from user JOIN role ON FIND_IN_SET(role.id,user.user_group) GROUP BY user.id
最后结果:

现在有这样的两个表
A表:
B表
我现在要查询A表中的id,name和B表中的cname
解决方法:
select user.id,user.name,GROUP_CONCAT(role.role_name) as b_name from user JOIN role ON FIND_IN_SET(role.id,user.user_group) GROUP BY user.id
最后结果:
本文标题:双表联查,如何通过数组查询对应的数据
本文链接:https://www.haomeiwen.com/subject/odpauftx.html
网友评论