select c.consume_name, --group_concat这里是关键
group_concat(a.poi_id Separator ';') as poi_id, group_concat(a.consume_id Separator ';') as consume_id, b.product_num,b.product_name,a.consume_id from eboos_product_consume_relation a INNER JOIN eboos_combination_product b on a.product_id=b.common_product_id left join eboos_consume c on a.consume_id=c.id where c.consume_name like '%江%' group by a.product_id查询的结果
现在只要再加上id的关联查找name,这样就可以得到了同一行数据根据某个特定的字段拆分成多条数据的效果了
博客地址:点击打开链接