sqlserver 交叉去重

SELECT * FROM [dbo].[I_Friend] T1
WHERE NOT EXISTS(SELECT 1 FROM [dbo].[I_Friend] T2 WHERE T1.UserId=T2.FriendUserId
AND T1.FriendUserId=T2.UserId AND T1.UserId>T2.UserId) and T1.UserId!= T1.FriendUserId

表名:I_Friend

去重的两个字段:UserId,FriendUserId

 

posted @ 2020-06-30 09:50  Smile灬Lucky  阅读(215)  评论(0编辑  收藏  举报