Skip to content

Instantly share code, notes, and snippets.

@olimortimer
Last active December 25, 2015 06:29
Show Gist options
  • Save olimortimer/6932037 to your computer and use it in GitHub Desktop.
Save olimortimer/6932037 to your computer and use it in GitHub Desktop.
MySQL: Find Duplicates
-- Duplicate count
SELECT <column>, COUNT(*) count FROM <table> GROUP BY <column> HAVING count > 1;
-- Find duplicates
SELECT * FROM <table>
INNER JOIN (SELECT <column> FROM <table>
GROUP BY <column> HAVING count(id) > 1) duplicate ON <table1>.<column> = duplicate.<column>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment