Select NOT IN multiple columns

前端 未结 4 1516
闹比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:28

    I use a way that may look stupid but it works for me. I simply concat the columns I want to compare and use NOT IN:

    SELECT *
    FROM table1 t1
    WHERE CONCAT(t1.first_name,t1.last_name) NOT IN (SELECT CONCAT(t2.first_name,t2.last_name) FROM table2 t2)
    

提交回复
热议问题