I want to add a UNIQUE index to a table, like this:
ALTER TABLE `mytable` ADD UNIQUE `myunique_name`(`first`, `second`, `third`);
Mysql responds with:
Duplicate entry '1-2-3' for key 'myunique_name'
I know for sure that this combination is just one out of thousands that violate the constraint.
In this special case I know for sure that all the rows that contain the same values in the three specified columns also contain the same data in the other relevant fields (the primary index differs of course, but is irrelevant), therefore all the duplicates can be deleted.
Is there a way to do delete all duplicate entries but keep one (doesn't matter which primary key is kept) so that the unique index can be added?