Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / August 2005

Tip: Looking for answers? Try searching our database.

delete duplicates from a duplicate querey

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ArnoldJ - 03 Aug 2005 14:50 GMT
I have many duplicates in a table after running a duplicate querey.  I want
Access to tell me how to delete just the duplicate rows.
Nikos Yannacopoulos - 03 Aug 2005 14:54 GMT
Arnold,

It is actually easier to use a Select query on the table and activate
Totals so you get unique records only, change that into a Make Table
query and produce a new table without duplicates, then get rid of the
original one and rename the new one to the original name.

Tip: back up before you try anything!

HTH,
Nikos
kelly d - 25 Aug 2005 23:53 GMT
Nikos, would you be willing to elaborate on this technique of using a select
query with totals to get unique values, I tried what you mentioned, turned on
totals, left my totals as 'group by' but it didnt work, I still had
duplicates in my query so I dont think I understood what you meant if you
could offer a step by step of how this select query with totals to get rid of
duplicates thing works.
thanks
-kelly.

>Arnold,
>
[quoted text clipped - 7 lines]
>HTH,
>Nikos
Eric D - 26 Aug 2005 14:29 GMT
The following query removes all duplicates from the delegate table, leaving
only the originals of the duplicated record. Here, we define a record as
having a duplicate if there is another record with matching FirstName and
LastName fields. This query relies on a view being set up that returns a list
of duplicate delegates. The view is called DupDels.

DELETE from Delegate
WHERE DelegateID =
ANY (SELECT DupDels.DelegateID
    FROM DupDels LEFT JOIN
         (SELECT Min(DelegateID) AS DelegateID, FirstName, LastName
         FROM DupDels GROUP BY FirstName, LastName) AS FirstDup
         ON DupDels.DelegateID = FirstDup.DelegateID
    WHERE FirstDup.DelegateID IS NULL

I recently found this code as I was searching for the same issue. I have
provided an exact copy of the post I found... it is not mine and I do not
take credit.... but it DOES work!

Delegate = Your table
DupDels = Your Find Duplicates Query
Table should have an ID field. If you don't have one, copy table and add an
ID field.
    The SELECT Min(....    uses three fields, but you can add more if needed.

FirstDup = temp table (created by above query)

The way this works is it finds the Min ID of each set of duplicate records
and stores the ID, FirstName and LastName in the temp table called FirstDup.
This portion runs against your Find Duplicates query. It then uses the temp
table and deletes each record in the Delegate table that has the same
FirstName and LastName but where the ID field does not match (the original)

Make a copy of your target table, modify this query to fit your tables/fields
and test it out.

I import Excel records that contain many duplicate entries. I then run a Find
Duplicates query (stored) and then the above delete query to filter out the
duplicates.

>I have many duplicates in a table after running a duplicate querey.  I want
>Access to tell me how to delete just the duplicate rows.
kelly d - 27 Aug 2005 16:11 GMT
Fantastic! that query's so cool it's almost like a magic trick. thanks for
your reply.

>The following query removes all duplicates from the delegate table, leaving
>only the originals of the duplicated record. Here, we define a record as
[quoted text clipped - 38 lines]
>>I have many duplicates in a table after running a duplicate querey.  I want
>>Access to tell me how to delete just the duplicate rows.

Signature

Kelly D

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.