How to delete all duplicate records from SQL Table?

后端 未结 4 446

Hello I have table name FriendsData that contains duplicate records as shown below

fID UserID  FriendsID       IsSpecial      CreatedBy
---         


        
4条回答
  •  长情又很酷
    2020-12-30 14:26

    Try this

    DELETE
    FROM FriendsData 
    WHERE fID NOT IN
    (
    SELECT MIN(fID)
    FROM FriendsData 
    GROUP BY UserID, FriendsID)
    

    See here

    Or here is more ways to do what you want

    Hope this helps

提交回复
热议问题