Select NOT IN multiple columns

前端 未结 4 1493
闹比i
闹比i 2020-12-12 18:03

I need to implement the following query:

SELECT * 
FROM   friend 
WHERE  ( friend.id1, friend.id2 ) 
         NOT IN (SELECT id1, 
                        id         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 18:43

    I'm not sure whether you think about:

    select * from friend f
    where not exists (
        select 1 from likes l where f.id1 = l.id and f.id2 = l.id2
    )
    

    it works only if id1 is related with id1 and id2 with id2 not both.

提交回复
热议问题