Last active
December 25, 2015 06:29
-
-
Save olimortimer/6932037 to your computer and use it in GitHub Desktop.
MySQL: Find Duplicates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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