Mehic.info

Quick way to remove duplicates from MySQL database

DROP TABLE IF EXISTS tmp;create table tmp like mytable;
ALTER TABLE tmp ADD UNIQUE INDEX(text1, text2, text3, text4, text5, text6);
insert IGNORE into tmp select * from mytable;
delete from mytable where id not in ( select id from tmp);
DROP TABLE IF EXISTS tmp;