gjshah7254
4/14/2014 - 10:19 PM

Check for Duplicate Listing

Check for Duplicate Listing

--RUn this query more than 1 time to delete all the duplicates--
DELETE FROM table1 
WHERE id IN ( 
     SELECT MIN(id) FROM table1 --you can delete the MIN or MAX based on ID
     GROUP BY col1, col2, col3 --columns which makes it to duplicate
     -- could add a WHERE clause here to further filter
     HAVING count(*) > 1
)
select ListingID, count(*)
  from Listing
  group by ListingId
  having count(*) > 1