Created
January 23, 2013 08:35
-
-
Save jcisio/4603181 to your computer and use it in GitHub Desktop.
MySQL table deduplication
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
-- Deduplication on all rows | |
CREATE TEMPORARY TABLE bad_temp AS SELECT DISTINCT * FROM your_table; | |
DELETE FROM your_table; | |
INSERT INTO your_table SELECT * FROM bad_temp; | |
-- Deduplication on some rows | |
CREATE TEMPORARY TABLE bad_temp AS SELECT * FROM your_table GROUP BY field1, field2, field3; | |
DELETE FROM your_table; | |
INSERT INTO your_table SELECT * FROM bad_temp; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment