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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Duplicate Entries

Status
Not open for further replies.

bhsbj

Vendor
Jan 14, 2003
3
US
Could someone please give me an example of how I can go through and remove duplicate entries? Let's say I have 20 names that are the same; however, I want to remove 19 of thoses names and just keep the one. Is there a way to do this? Thanks for any help.
 
I did something similar by creating a second table and using a series of queries.

Let's call the original table TableA. I created TableB by copying the structure of TableA. It then created a query to copy distint values from TableA to TableB (this gets rids of duplicates, but keeps the original). My next query deleted the data from TableA. My final query copied the data from TableB back to TableA.

This is not efficient for large amounts of data, nor is it the advised approach. The better approach is to prevent duplicates in the first place. The above patch was used because I forgot to screen out duplicates.

Hope that helps.
 
Open a query by design and show the tab;le you are interested in.

Select all fields, right click on the grey area next to the table, under properties select Unique Records as YES

Run the query with the exclamation mark to confirm what you get is what you expect.

click back to design mode and change the query type to make table. (you decide the name)

run the query again.

Delete the first table and rename the new table to the old table's name.

HTH

telephoto
 
telephoto's method is faster if you only need to do it once. The method I suggested works better if you want to automate this to run periodically.

telephoto,
the one suggestion I have is instead of using the exclamation mark to preview the results, I find it easier to get in the habit of using the preview view. The reason I prefer this is it will show you which records are being selected without actually running the query. This allows you to view the records selected whether it is a select, make-table, update, delete, etc. query
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top