mysql查询某个值在分组中出现多次的数据

       场景:一个商品可以按照不同的规格进行售卖,比如玉米,可以一粒装或三粒装等规格进行售卖,现在我想查看有哪些商品是按照多个规格进行售卖的,sql如下所示:

select GROUP_CONCAT(d.specification_id),d.goods_id from 
(select b.specification_id specification_id,b.specification_name specification_name
,c.goods_id goods_id from send_order a join send_order_extend b on a.send_order_id=b.send_order_id join send_order_goods c on a.send_order_id=c.send_order_id
where a.delivery_date='2019-06-25' GROUP BY b.specification_id,c.goods_id) d GROUP BY d.goods_id HAVING count(*)>1

你可能感兴趣的:(Mysql)