List:General Discussion« Previous MessageNext Message »
From:Philip Hallstrom Date:September 13 2006 1:55am
Subject:Re: query to find duplicate rows
View as plain text  
>> Hi all, a though query problem for me...
>> 
>> I have a table with 2 rows that matter: url and id
>> 
>> If url and id are the same in 2 rows, then that's no good (bad data).
>> 
>> I need to find all the rows that are duplicates. I can't think of how
>> to approach the sql for this.. any pointers?
>> 
>
> Select COUNT(*) as num_entries, url from table WHERE num_entries>1 GROUP BY 
> url
>
> Untested, but the concept should work for you.

That would mark rows that have different id's, but the same url...

SELECT t1.id, t2.id, t1.url
FROM table t1, table t2
WHERE t1.id = t2.id
   AND t1.url = t2.url

Expensive if you have a lot of rows, but should work I think... if my 
memory is right :)
Thread
query to find duplicate rowsPeter Van Dijck13 Sep
  • Re: query to find duplicate rowsSteve Musumeche13 Sep
    • Re: query to find duplicate rowsPhilip Hallstrom13 Sep
      • Re: query to find duplicate rowsChris13 Sep
        • Re: query to find duplicate rowsPhilip Hallstrom13 Sep
          • Re: query to find duplicate rowsChris14 Sep
  • Re: query to find duplicate rowsBrent Baisley13 Sep