Created
March 27, 2019 13:39
-
-
Save geo-stanciu/44ba722af2c19b722a68ac70176749e0 to your computer and use it in GitHub Desktop.
Clear Duplicate Rows
This file contains 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
psql -d devel | |
-- delete duplicate rss - postgresql | |
DELETE FROM rss T1 | |
USING rss T2 | |
WHERE T1.ctid < T2.ctid | |
AND T1.rss_source_id = T2.rss_source_id | |
AND T1.title = T2.title | |
AND T1.link = T2.link; | |
\q | |
mysql devel | |
-- delete duplicate rss - mysql | |
DELETE T1 FROM rss T1 | |
INNER JOIN rss T2 | |
WHERE T1.rss_id < T2.rss_id | |
AND T1.rss_source_id = T2.rss_source_id | |
AND T1.title = T2.title | |
AND T1.link = T2.link; | |
\q | |
sqlcmd -d devel | |
-- duplicate rss - sql server | |
WITH r AS ( | |
SELECT ROW_NUMBER() OVER(PARTITION by rss_source_id, title, link ORDER BY rss_id DESC) AS row | |
FROM rss | |
) | |
DELETE FROM r | |
WHERE row > 1; | |
go | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment