mysql SELECT NOT IN () — disjoint set?

后端 未结 6 1599
我寻月下人不归
我寻月下人不归 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:50

    Well, I'm going to answer my own question, in spite of all the great advice others gave.

    Here's the proper syntax for what I was trying to do.

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

    Can't vouch for the efficiency of it, but the broader questions I was implicitly putting was "How do I express this thought in SQL", not "How do I get a particular result set". I know that's unfair to everyone who took a stab, sorry!

提交回复
热议问题