toledorobia
1/8/2018 - 8:48 PM

MYSQL - Remove duplicate rows

MYSQL - Remove duplicate rows

-- The greater ID:
DELETE n1 FROM names n1, names n2 WHERE n1.id > n2.id AND n1.name = n2.name

--The lower ID:
DELETE n1 FROM names n1, names n2 WHERE n1.id < n2.id AND n1.name = n2.name