finding duplicates and removing but keeping one value
I currently have a URL redirect table in my database that contains ~8000
rows and ~6000 of them are duplicates.
I was wondering if there was a way I could delete these duplicates based
on a certain columns value and if it matches, I am looking to use my
"old_url" column to find duplicates and I have used
SELECT old_url
,DuplicateCount = COUNT(1)
FROM tbl_ecom_url_redirect
GROUP BY old_url
HAVING COUNT(1) > 1 -- more than one value
ORDER BY COUNT(1) DESC -- sort by most duplicates
however I'm not sure what I can do to remove them now as I don't want to
lose every single one, just the duplicates. They are almost a match
completely apart from sometimes the new_url is different and the url_id
(GUID) is different in each time
No comments:
Post a Comment