Želite izbrisati vse podvojene vrstice razen ene v MySQL? [dvojnik]
Tabela uporabnikov ima 5 zapisov s podvojenim e-poštnim naslovom [email protected]
Iskanje vrne podvojena e-poštna sporočila v tabeli Uporabniki:
SELECT *, COUNT(email) FROM users
GROUP BY email
HAVING COUNT(email) > 1;
Izbrišite podvojene vrstice s stavkom DELETE JOIN
DELETE table1 FROM users table1
INNER JOIN users table2
WHERE table1.id < table2.id AND table1.email = table2.email
Rezultat