Delete querie maximum value

tubar

Registered User.
Local time
Today, 11:16
Joined
Jul 13, 2006
Messages
190
i have a delete querry that finds duplicate records but im having trouble adapting the SQL to delete the record with the highest id.
Code:
DELETE tblevent.F1, tblevent.ID, tblevent.F2, tblevent.*
FROM tblevent
WHERE (((tblevent.F1) In (SELECT [F1] FROM [tblevent] As Tmp GROUP BY [F1] HAVING Count(*)>1 )));
 
Last edited:
changed my sql...now the query will find duplicates and delete the duplicate record with the higher id
Code:
DELETE tblevent.id, *
FROM tblevent
WHERE (((tblevent.id) In (SELECT Max([id])
 FROM [Tblevent]
 GROUP BY [F1], [F1]
 HAVING Count([f1]) > 1)));
 

Users who are viewing this thread

Back
Top Bottom