Skip to content

Instantly share code, notes, and snippets.

@toledorobia
Created January 8, 2018 20:48
Show Gist options
  • Save toledorobia/42337e9d25e14b49f2e92159ca91fe3b to your computer and use it in GitHub Desktop.
Save toledorobia/42337e9d25e14b49f2e92159ca91fe3b to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment