QuePID Posted August 13, 2010 Share Posted August 13, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/210608-handling-duplicates/ Share on other sites More sharing options...
Festy Posted August 13, 2010 Share Posted August 13, 2010 use 'SELECT DISTINCT......' query to fetch unique rows. Quote Link to comment https://forums.phpfreaks.com/topic/210608-handling-duplicates/#findComment-1098743 Share on other sites More sharing options...
kickstart Posted August 13, 2010 Share Posted August 13, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/210608-handling-duplicates/#findComment-1098840 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.