Created
March 13, 2013 00:16
-
-
Save fweep/5148336 to your computer and use it in GitHub Desktop.
Clean up duplicate rows in a PostgreSQL table with differing IDs
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
-- Expensive sub-query method: | |
delete from questions_tags qt using questions_tags qt2 where qt.question_id = qt2.question_id and qt.tag_id = qt2.tag_id and qt.id != qt2.id and qt.id not in (select min(id) from questions_tags qt3 where qt.question_id = qt3.question_id and qt.tag_id = qt3.tag_id); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment