Ejemplo 1: mysql eliminar duplicados
DELETE FROM table_name WHERE id
NOT IN ( SELECT id FROM table_name
GROUP BY field_1, field_2)
Ejemplo 2: mysql elimina duplicados antiguos
delete test
from test
inner join (
select max(id) as lastId, email
from test
group by email
having count(*) > 1) duplic on duplic.email = test.email
where test.id < duplic.lastId;
Ejemplo 3: mysql eliminar duplicados
DELETE t1 FROM contacts t1
INNER JOIN contacts t2
WHERE
t1.id < t2.id AND
t1.email = t2.email;Code language: SQL (Structured Query Language) (sql)
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)