使用group_concat 实现查询父子表时一并将子表内容使用逗号分割组合查询出来
2022年9月19日
有fx_example_items A表为父表,有fx_example_options B表为子表。需要使用一条SQL将A表和B的内容一并查询出来。
1 2 3 4 5 6 |
select b.*, c.content from fx_example_items b, (select example_id, group_concat(content) as content from fx_example_options c group by example_id) as c where b.id = c.example_id |