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. Para eliminar los duplicados de una base de datos MySQL cuadro I normalmente copia el duplicado de datos en primer lugar a una tabla temporal y luego usar el id del copiado a eliminar de la tabla original.

Delete using the temporary can take two forms. Eliminar el uso temporal puede hacerse de dos maneras. First is the slow way: El primero es el modo lento:

delete from target where id in (select id from temp); suprimir el objetivo de que el ID (identificador de seleccionar temp);

This can be agonizingly slow for a large table. Esto puede ser lentos para una gran mesa. A much faster option is: Una opción mucho más rápida es la siguiente:

delete target from target, temp where target.id = temp.id; suprimir el objetivo de la meta, donde target.id temp = temp.id;

BTW: The copying into temporary table part is simple but not that simple. BTW: La copia en tabla temporal parte es simple pero no así de sencillo. Here’s what I do: Esto es lo que debo hacer:

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 ; insert into temp (id) b.id de seleccionar un objetivo, objetivo que a.common_field1 b = b.common_field1 y a.common_field2 = b.common_field2… y a.id <b.id;

Note: I am assuming all the tables have an unique row identifier (primary key). Nota: Estoy suponiendo que todos los cuadros tienen un único identificador de fila (clave primaria).