I need to find duplicate emails in our database. I am looking on one table for this information. What I have so far
SELECT name.email, name.ID
From Name
Group BY Name.ID, Name.EMAIL
Having Count(*) > 1
I know that its wrong, but not sure how to write it appropriately.
Select a mailbox folder. Select Home > Cleanup. Now, configure the below options: Clean up Conversation will delete and move the duplicate emails that are in the conversation.
The problem: Gmail allows multiple e-mail addresses for a single account.
remove the ID
SELECT name.email
From Name
Group BY Name.EMAIL
Having Count(*) > 1
if you want to get the number of email,
SELECT name.email, COUNT(*) totalEmailCount
From Name
Group BY Name.EMAIL
Having Count(*) > 1
The query would be
SELECT name.email, COUNT(*) FROM Name
GROUP BY Name.email HAVING COUNT(*) > 1
What you need to know is that if you group also by ID the count would be 1, thats why your query didn't work.
If you need to know the IDs of the users with emails duplicated you can do this:
select Name.ID, Name.Email from Name where Name.Email in (
SELECT name.email FROM Name
GROUP BY Name.email HAVING COUNT(*) > 1
)
The below SQL query will return the ID and EMAIL of the first matching row which contain the same(duplicate) EMAIL
select ID, EMAIL from Name group by EMAIL having count(EMAIL) > 1
If someone, wants all the duplicate EMAIL from the Name table then, he/she can execute the following SQL query
select EMAIL from Name group by EMAIL having count(EMAIL) > 1
Note that: SQL is a fully case-insensitive language.
Here you go:
SELECT name.email, COUNT(*)
FROM
Name
GROUP BY
Name.email
HAVING
COUNT(*) > 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With