Skip to content

Instantly share code, notes, and snippets.

@payamomrani
Created September 21, 2020 06:48
Show Gist options
  • Save payamomrani/d68f91de2e9229ae8c2388d94d34f480 to your computer and use it in GitHub Desktop.
Save payamomrani/d68f91de2e9229ae8c2388d94d34f480 to your computer and use it in GitHub Desktop.
// Find Duplicate Rows//
SELECT
email, COUNT(email)
FROM
contacts
GROUP BY
email
HAVING
COUNT(email) > 1;
// End //
//Delete Duplicate Rows//
DELETE c1 FROM contacts c1
INNER JOIN contacts c2
WHERE
c1.id > c2.id AND
c1.email = c2.email;
// End //
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment