PC Review


Reply
Thread Tools Rate Thread

deletion of duplicates records

 
 
=?Utf-8?B?ZGVsZXRlIGR1cGxpY2F0ZXM=?=
Guest
Posts: n/a
 
      11th Feb 2006
In my database there are duplicate surnames, first_names, Initial,
the duplicates query can only get them out instead of the delete query to
delete just one of the duplicate records it will delete all the records
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmVycnkgV2hpdHRsZQ==?=
Guest
Posts: n/a
 
      11th Feb 2006
Need more info. What are all the field names in the table? Is there a
primary key on the table? Do you have nearly duplicate names such as not
having a middle initial, but still considered the same person? Does the table
contain a foreign key to any other tables>
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"delete duplicates" wrote:

> In my database there are duplicate surnames, first_names, Initial,
> the duplicates query can only get them out instead of the delete query to
> delete just one of the duplicate records it will delete all the records

 
Reply With Quote
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      11th Feb 2006
Firstly add an autonumber column to the table if you don't have one already.
Lets call it ContactID. That will serve to uniquely identify each row. You
can then delete all but one row of each duplicated surname, first_name,
initial combination by using a subquery to identify all but those with the
lowest ContactID value. So, assuming the table is called Contacts the delete
query would go like this:

DELETE *
FROM Contacts AS C1
WHERE ContactID >
(SELECT MIN(ContactID)
FROM Contacts AS C2
WHERE C2.surname = C1.surname
AND C2.first_name = C1.first_name
AND C2,initial = C1.Initial);

Be sure to back up the table first!

Ken Sheridan
Stafford, England

"delete duplicates" wrote:

> In my database there are duplicate surnames, first_names, Initial,
> the duplicates query can only get them out instead of the delete query to
> delete just one of the duplicate records it will delete all the records

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto deletion of duplicates mrwhitescotland Microsoft Access Queries 5 11th Sep 2008 02:58 PM
how do I highlight duplicates cells in excell prior to deletion =?Utf-8?B?UGF1bCBC?= Microsoft Excel Worksheet Functions 6 21st Aug 2007 12:08 PM
How to limit deletion of records? =?Utf-8?B?Z2c=?= Microsoft Access Form Coding 10 6th Jan 2006 12:21 AM
deletion of records Lauren B Microsoft Access Forms 1 15th Feb 2005 09:35 PM
Protect only certain records from deletion =?Utf-8?B?Umljb3ktQ2hpY2Fnbw==?= Microsoft Access Form Coding 4 3rd Feb 2005 04:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:09 PM.