Jump to content

Handling duplicates


QuePID

Recommended Posts

I have a large table with roughly thousands of duplicates in a field which should have been unique.

 

I need a way of creating a new table with all the duplicate records for later sorting.

 

I have a duplicate-free copy of the old table saved as a new table.

 

I have tried

CREATE TABLE iknew1 as SELECT iknew.*, COUNT(*) FROM iknew GROUP BY Accession HAVING COUNT(*) > 1

 

But this only copies one of the duplicated records not both, and I will need both records for comparison and to aid determining if the dupes are from data entry.

 

Link to comment
https://forums.phpfreaks.com/topic/210608-handling-duplicates/
Share on other sites

Hi

 

I think what you are trying to get is every duplicate of duplicated records from the table but ignoring any record that isn't duplicated, with Accession being duplicated over multiple rows.

 

If so then something like this:-

 

SELECT a.*
FROM iknew a
INNER JOIN (SELECT Accession, COUNT(*) FROM iknew GROUP BY Accession HAVING COUNT(*) > 1) b ON a.Accession = b.Accession

 

All the best

 

Keith

Link to comment
https://forums.phpfreaks.com/topic/210608-handling-duplicates/#findComment-1098840
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.