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

Self Join

Status
Not open for further replies.

shultz

Programmer
Joined
Oct 28, 2001
Messages
42
Location
HK
Can anybody tell me how to delete duplicate records from a table.

I have the following fields in "tblAction" table.

ID - Auto Number
CSRSR - varchar(20)
Action - varchar(2000)

And here, I want to delte those records where "Action" has been repeated or duplicated.

thanks a lot.
 
If you want to keep the one with the highest Id:

Delete tblAction
From tblAction A Inner Join (Select Action, Max(Id) as Max_Id From tblAction Group By Action) B
On A.Action = B.Action
Where A.Id <> B.Max_Id

Or change it to Min() if you want the lowest Id.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top