Skip to content

Instantly share code, notes, and snippets.

@stajnert
Created August 21, 2012 07:08
Show Gist options
  • Save stajnert/3412980 to your computer and use it in GitHub Desktop.
Save stajnert/3412980 to your computer and use it in GitHub Desktop.
Get duplicates from mysql
Single records:
SELECT column, COUNT(*) AS c
FROM table
GROUP BY column
HAVING COUNT(c) > 1
All records:
SELECT *
FROM table
WHERE column IN (
SELECT column
FROM table
GROUP BY column
HAVING count(column) > 1
)
ORDER BY column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment