It's easy to find duplicates
with one field:
(使用一个字段很容易找到duplicates
:)
SELECT name, COUNT(email)
FROM users
GROUP BY email
HAVING COUNT(email) > 1
So if we have a table
(所以,如果我们有一张桌子)
ID NAME EMAIL
1 John [email protected]
2 Sam [email protected]
3 Tom [email protected]
4 Bob [email protected]
5 Tom [email protected]
This query will give us John, Sam, Tom, Tom because they all have the same email
.
(这个查询将给我们John,Sam,Tom,Tom,因为他们都有相同的email
。)
However, what I want is to get duplicates with the same email
and name
.
(但是,我想要的是使用相同的email
和name
获取重复项。)
That is, I want to get "Tom", "Tom".
(也就是说,我想得到“汤姆”,“汤姆”。)
The reason I need this: I made a mistake, and allowed to insert duplicate name
and email
values.
(我需要这个的原因:我犯了一个错误,并允许插入重复的name
和email
值。)
Now I need to remove/change the duplicates, so I need to find them first. (现在我需要删除/更改重复项,所以我需要先找到它们。)
ask by Alex translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…