[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    Re: Finding duplicates
From:       Chris <dmagick () gmail ! com>
Date:       2006-10-31 6:14:32
Message-ID: 4546E9C8.4050708 () gmail ! com
[Download RAW message or body]

Chris W wrote:
> Chris wrote:
>> Chris W wrote:
>>> Suppose I have table t with fields k1, k2 and k3 that all make up the 
>>> primary key.  Then I have fields x, y and z.  If fields x, y and z 
>>> all have the same values in more than one row, there is a good chance 
>>> they are duplicate records.  What is the best way to list all of the 
>>> rows where this condition exists?
>>
>> Something like:
>>
>> select k1, k2, k3 from table group by k1, k2, k3 having count(*) > 1;
>>
> I don't think I was clear, x, y, and z are not the only rows in the 
> table and the group of k1, k2, k3 will always be unique as it is a 
> unique primary key.
> 

Adjust the query:

select x, y, z from t group by x,y,z having count(*) > 1;

That will tell you which values of x,y,z you need to look at.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=mysql@progressive-comp.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic