Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.