表一:login
id | cids | state |
1 | 1,2 | 1 |
表二:learn
id | name |
1 | zhangsan |
2 | lisi |
3 | wangwu |
select g.id, GROUP_CONCAT(s.name) as sname from login g left join tlearn s on FIND_IN_SET(s.id, g.cids) GROUP BY g.id
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:mysql 一表字段逗号分隔对应另一表字段查询 - Python技术站