MySQL列出所有重复项

MySQL列出所有重复项,第1张

MySQL列出所有重复

SELECt a., b.totalCount AS Duplicate
FROM tablename a
INNER JOIN
(
SELECt email, COUNT(


) totalCount
FROM tableName
GROUP BY email
) b ON a.email = b.email
WHERe b.totalCount >= 2

  • SQLFiddle演示

为了获得更好的性能,请添加一个

INDEX
on列
EMail

或者

SELECt  a.*, b.totalCount AS DuplicateFROM    tablename a        INNER JOIN        ( SELECt  email, COUNT(*) totalCount FROM    tableName GROUP   BY email HAVINg  COUNT(*) >= 2        ) b ON a.email = b.email
  • SQLFiddle演示


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5640691.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存