mysql查询某个值在分组中出现多次的数据
Posted 在京奋斗者
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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查询某个值在分组中出现多次的数据的主要内容,如果未能解决你的问题,请参考以下文章