Delete all Duplicate Rows except for One in MySQL? [duplicate]
The user table has 5 records with duplicate [email protected] email
Search returns the duplicate emails in the Users table:
SELECT *, COUNT(email) FROM users
GROUP BY email
HAVING COUNT(email) > 1;
Delete duplicate rows using DELETE JOIN statement
DELETE table1 FROM users table1
INNER JOIN users table2
WHERE table1.id < table2.id AND table1.email = table2.email
Result