Thanks for your help. 

________________________________

From: Peter Brawley [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 02, 2007 10:47 AM
To: Weston, Craig (OFT); mysql@lists.mysql.com
Subject: Re: [mysql] reverse join

 

Craig



>How do I pull out all the non-duplicate records?

With an exclusion join. To find non-duplicates with respect to one
key...

SELECT keycandidate
FROM tbl t1
LEFT JOIN tbl t2 ON t1.keycandidate=t2.keycandidate
WHERE t2.keycandidate IS NULL;

To expand the comparison to multiple keys...

SELECT key1, key2, ...
FROM tbl t1
LEFT JOIN tbl t2 ON t1.key1=t2.key2 AND t1.key2=t2.key2 AND ...
WHERE t2.key1 IS NULL;

PB

Weston, Craig (OFT) wrote: 

Hi there, 
 
            I have a situation where I have duplicate data within
several tables, but they are all indexed in the same way.  How do I pull
out all the non-duplicate records?
 
 
 
 
 
Would I have to create a temporary table, add one data set, then add the
second where it doesn't equal the first, and then do the same with the
third? Or is there a cleaner way?
 
 
 
 
 
Thanks,
 
Craig
--------------------------------------------------------
This e-mail, including any attachments, may be confidential, privileged
or otherwise legally protected. It is intended only for the addressee.
If you received this e-mail in error or from someone who was not
authorized to send it to you, do not disseminate, copy or otherwise use
this e-mail or its attachments.  Please notify the sender immediately by
reply e-mail and delete the e-mail from your system.
 
  
 



________________________________



 
No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.2/931 - Release Date: 8/1/2007
4:53 PM
  

Reply via email to