mysql SELECT NOT IN () — disjoint set?

后端 未结 6 1587
我寻月下人不归
我寻月下人不归 2021-02-20 11:22

I\'m having a problem getting a query to work, which I think should work. It\'s in the form

SELECT DISTINCT a, b, c FROM t1 WHERE NOT IN ( SELECT DISTINCT a,b,c          


        
6条回答
  •  别跟我提以往
    2021-02-20 11:53

    Need to add a column list after the WHERE clause and REMOVE the alias.

    I tested this with a similar table and it is working.

    SELECT DISTINCT a, b, c 
    FROM t1 WHERE (a,b,c)
    NOT IN (SELECT DISTINCT a,b,c FROM t2)
    

    Using the mysql world db:

    -- dont include city 1, 2
    SELECT DISTINCT id, name FROM city 
    WHERE (id, name) 
    NOT IN (SELECT id, name FROM city  WHERE ID IN (1,2))
    

提交回复
热议问题