mysql - SQL 查询 - 查找重复条目
问题描述
我在 MySQL 服务器上有这种表,其中包含重复的条目:
我想建立一个查询,它将为我提供所有 transID 的列表,其中客户端和/或名称、电话、邮件中有重复条目。因此,在这种情况下,结果将是:
所以:TransID1、TransID2、TransID3、TransID5、TransID9、TransID10
我尝试了几种组合都没有成功。
解决方案
您可以使用exists
:
select t.*
from t
where exists (select 1
from t t2
where (t2.name = t.name or t2.phone = t.phone or t2.mail = t.mail) and
t2.transid <> t.transid
);
推荐阅读
- javascript - 带有类的新音频(url)
- python - sklearn simpleimputer 不会填充缺失的分类 NaN 值
- css - 如何使滚动条仅在使用时可见?
- java - 如何在java swing中获取鼠标的实时位置?
- css - 我的 css 文件(即包括我通过 CDN 的引导程序)突然停止在生产服务器上工作
- regex - 使用正则表达式在花括号内分组花括号
- ruby-on-rails - 在控制器中设计令牌身份验证并设计重复
- python - 带有 axios 的 HTTP POST:net::ERR_EMPTY_RESPONSE
- r - 尝试导入 excel 文件,显示错误消息不允许我导入
- ssh - Goland 远程调试