Created
November 15, 2015 16:07
-
-
Save selfish/8a6129e281b2b723a6b7 to your computer and use it in GitHub Desktop.
Delete duplicates MySQL table, leaving one row for each duplicate group
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
| DELETE `t1` | |
| FROM `table` `t1` | |
| INNER JOIN `table` `t2` | |
| ON `t1`.`dup_col1` = `t2`.`dup_col1` | |
| AND `t1`.`dup_col2` = `t2`.`dup_col2` | |
| # AND... | |
| WHERE `t1`.`primary_key` > `t2`.`primary_key` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment