Created
March 16, 2015 17:37
-
-
Save bgadrian/98509f1575cabc25da03 to your computer and use it in GitHub Desktop.
MYSQL Look for duplicate rows, in the same table, by a different column (not primary or unique).
This file contains hidden or 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
SELECT p1.id,p1.cod , p2.id,p2.cod #here we find the duplicate data from cod column, but i need the ID to show ... | |
FROM `st_produse` p1 #the table, first time | |
LEFT JOIN st_produse p2 ON p1.cod = p2.cod #the table second time | |
WHERE p1.id <> p2.id #here put the key or a unique column | |
GROUP BY p1.cod #the c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment