To delete duplicates from a MySQL database table I normally copy the duplicate data first to a temporary table and then use the copied id’s to delete from the original table.重複を削除する普段からテーブルをMySQLのデータベースに重複するデータにコピーして最初にテンポラリテーブルと入力し、番号のコピーを使用して、元のテーブルを削除するからです。

Delete using the temporary can take two forms.削除するには2つのフォームを使用して、一時的です。 First is the slow way:最初は、低速な方法:

delete from target where id in (select id from temp); ターゲットどこから番号を削除する(選択番号から気温) ;

This can be agonizingly slow for a large table.これは大きな苦痛を伴うほど遅いの表のとおりです。 A much faster option is:もずっと速いオプションは:

delete target from target, temp where target.id = temp.id; ターゲットから削除するターゲットは、気温がtarget.id = temp.id ;

BTW: The copying into temporary table part is simple but not that simple.ところで:テンポラリテーブルにコピーするには、シンプルでありながらそれほど単純ではない部分です。 Here’s what I do:ここは何か、僕は:

insert into temp(id) select b.id from target a, target b where a.common_field1 = b.common_field1 and a.common_field2 = b.common_field2 … and a.id < b.id ; 挿入さ気温(番号)を選択しb.idをターゲットにするより、ターゲットBどこa.common_field1 = b.common_field1とb.common_field2 …とa.common_field2 = a.id < b.id ;

Note: I am assuming all the tables have an unique row identifier (primary key).注:私は仮定のすべてのテーブルの行があるユニークな識別子(主キー) 。