Delete query

  • Thread starter Thread starter Domac
  • Start date Start date
D

Domac

Hi,


I need to delete duplicates from table, i have located records that are
duplicated using count >1.
But it returns about 200 records , so it would be gruelling to delete it by
hand.


So i need a query that goes about like this:


DELETE First(*) where Exist (MyDuplicateRecordListQuery)

Can I use First in this context??

Please help.
 
I would first identify the records you want to delete by the duplicate
value(s) and the First of their Primary Key value:

SELECT DISTINCTROW LastName, First(StudentID) AS FirstID
FROM tblStudents
GROUP BY tblStudents.LastName
HAVING (((LastName) In (SELECT [LastName] FROM [tblStudents] As Tmp GROUP BY
[LastName])));

Now, you have the ID values, which I'd write to a new temporary table. Link
the temporary table back to the original table on the Primary Key, and run
the query. Delete anything that you find, and compact the database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top