Skip to content

Instantly share code, notes, and snippets.

@bensie
Created May 16, 2012 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bensie/2706330 to your computer and use it in GitHub Desktop.
Save bensie/2706330 to your computer and use it in GitHub Desktop.
Find duplicate rows in MySQL
# Assumes you're looking to add a unique index to [:field1, :field2] and want to find duplicates to remove/fix them
SELECT id, field1, field2, count(*) FROM table GROUP BY field1, field2 HAVING count(*) > 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment