mysql如何查询两个字段存在两条以上的相同数据?

作者站长头像
站长
· 阅读数 15

求救,比如我想查找所以 zxtId,billUuid,这两个字段存在 个以上重复的数据,要怎么查询呢?

select *  from wx_material  group by zxtId,billUuid  having count(zxtId + billUuid) > 1

这样只显示的其中 1 条,我想要重复的所有比如

id   zxtId     billUuid   add
1    123       A009       0309号
2    123       A009       0310号
3    126       A011       0315号
4    126       A011       0322号
回复
1个回答
avatar
test
2024-07-13
SELECT
    b.* 
FROM
    app_duty_sign_in_range b,
    ( SELECT location, latitude FROM app_duty_sign_in_range GROUP BY location, latitude HAVING count( location + "" + latitude ) > 1 ) AS a 
WHERE
    a.location = b.location 
    AND a.latitude = b.latitude

类似这种,外面套一层select

回复
likes
适合作为回答的
  • 经过验证的有效解决办法
  • 自己的经验指引,对解决问题有帮助
  • 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
  • 询问内容细节或回复楼层
  • 与题目无关的内容
  • “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容