Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting duplicates from a table

Status
Not open for further replies.

jamesk1979

IS-IT--Management
May 22, 2003
15
AU
I have a table with the following fields;
cus_name
acc_num
acc_branch
cus_fname
cus_sname
etc...

I need a query which will scan through the table and delete any duplicates in the acc_num field (i.e. if there are 6 entries for 123456, I need to keep one and remove the other 5 from the table).

Can anybody help? I don't have any VBA experience so if you could explain the quickest way of doing it using the Access SQL view, that would be great.

Many Thanks.
 
Sorry, I need to keep the first instance and delete the remaining ones.

Cheers, r937...
 
well, right there is the nub of the problem

how do you define "first"?

is there an autonumber on each row?

is there a date field?

do you want to keep the row with the lowest customer name?

highest account balance?

if there is no other column that will assure that you can select exactly one row out of the duplicates, then the sql to eliminate duplicates will be substantially more complex


rudy
 
Yes, there is an autonumber value on each row.

I want to keep the row with the lowest autonumber value. Is this possible?

Thanks,
James.
 
sure, it's possible

set up a Make Table query (SELECT... INTO...) to save only the rows you want to keep (the ones with the lowest autonumber)

then delete the rows where the autonumber is not in the saved data

like this: thread701-686164

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top