I think you could just try adding UNIQUE INDEX using IGNORE:
ALTER IGNORE TABLE `table` ADD UNIQUE INDEX `name` (`column`);
MySQL should answer something like:
Query OK, 4524 rows affected (1.09 sec) Records: 4524 Duplicates: 9342 Warnings: 0
Of course, you will leave this until MySQL to decide which rows to discard.
EDIT:
this works for as many columns as possible:
ALTER IGNORE TABLE `table` ADD UNIQUE INDEX `name` (`col1`, `col2`, `col3`);
check MySQL documentation for CREATE INDEX . The usual magic (at least the one I came across once) is to forget that NULL = NULL not true (but NULL ), so {42, NULL} and {42, NULL} are allowed for the UNIQUE index on two columns.
sfussenegger
source share