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演示
为了获得更好的性能,请添加一个
INDEXon列
或者
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演示
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)