Finding Duplicate Entries in MySQL Database

I’ve been migrating a slew of customer contact data over for a client. The previous database entry submission form allowed contacts to sign up multiple times with the same email address. Since unique email submission was vital to the new functionality I had programmed into their customer contact management, I needed a quick way to sort through thousands of records to find duplicate ‘email’ addresses within the ‘prospect’ table.

Here is a simple MySQL statement to do the trick:

SELECT email,
COUNT(email) AS Duplicates
FROM prospect
GROUP BY email
HAVING ( COUNT(email) > 1 )

Comments are closed.