mysql 合并left join 数据条目
查询两张关联表信息,原sql:
SELECT * FROM car_life_info c
left JOIN shop_label sl
ON c.shop_id = sl.shop_id
出现重复 店铺名称
合并 后面列label
新sql:
SELECT c.*,group_concat(sl.label_id) label_ids ,group_concat(l.label_name ) label_names
FROM car_life_info c
LEFT JOIN shop_label sl
ON c.shop_id = sl.shop_id
LEFT JOIN label l
ON sl.label_id = l.label_id
group by shop_id
问题解决!