I have a MySQL table with 80,000 records. One of the columns is "email". I'd like to keep all 80,000 rows, but empty out each duplicate email value. Is this possible in MySQL directly?
Thanks in advance!
I have a MySQL table with 80,000 records. One of the columns is "email". I'd like to keep all 80,000 rows, but empty out each duplicate email value. Is this possible in MySQL directly?
Thanks in advance!
Assuming you want to remove the higher id
from the email_table.
DELETE e1
FROM email_table e1, email_table e2
WHERE e1.id > e2.id AND
e1.email = e2.email;
And enforce it for the future:
ALTER TABLE email_table ADD UNIQUE KEY email_unique(email);