Remove duplicate rows in MySQL

Rate this post

Easiest way to do this is to add a UNIQUE index on the column. When you write the ALTER statement, include the IGNORE keyword. Like so:

 ADD UNIQUE INDEX idx_name (site_id, title, company);

This will drop all the duplicate rows. As an added benefit, future INSERTs that are duplicates will error out. As always, you may want to take a backup before running something like this…

For any query or issue, feel free to discuss on

Leave a Reply

%d bloggers like this: