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

How to delete duplicate records via SQL.

Status
Not open for further replies.

benmillus

Programmer
Jun 17, 2003
18
US
Is it possible to convert this to delete the duplicate records as they are found? If so how? If not what would you suggest?

SELECT FLD1, FLD2, FLD3, FLD4
FROM DED05
WHERE ((FLD1 In (SELECT FLD1 FROM DED05 As Tmp GROUP BY FLD1,FLD2 HAVING Count(*)>1 And FLD2 = FLD2)))
ORDER BY FLD1, FLD2;
 
I can't find it right now, but I've seen a FAQ on this site about how to do this. Check the VBA forum for access. forum705

Jim DeGeorge [wavey]
 
Jim, Thanks for relying. I actually resolved this. The solution is:

DELETE TBL.*
FROM TBL
WHERE ((FLD1 In (SELECT FLD1 FROM TBL As Tmp GROUP BY FLD1,FLD2 HAVING Count(*)>1 And FLD2 = FLD2)));

BEN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top