Skip to content

Instantly share code, notes, and snippets.

@p0vidl0
Last active July 26, 2021 11:48
Show Gist options
  • Save p0vidl0/810d63a7e4445d9f2953ab8d20692a21 to your computer and use it in GitHub Desktop.
Save p0vidl0/810d63a7e4445d9f2953ab8d20692a21 to your computer and use it in GitHub Desktop.
Delete all duplicate rows based on the email field
DELETE c1 FROM `clients` c1, `clients` c2 WHERE c1.`id` < c2.`id` AND c1.`email` = c2.`email`;
@p0vidl0
Copy link
Author

p0vidl0 commented Jul 23, 2018

Useful before creating unique index for field email. Leaves one row of duplicates with greatest id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment