不能用not in,因为有3个字段,表A主键有3个字段,现在要求求3个字段同时满足某种条件的记录之外的记录,该怎样写sql?感觉要用not exists,但不会写,求指导

解决方案 »

  1.   

    select *
    from ..
    where
    not (同时满足某种条件)
      

  2.   


    select 

    from tb
    where 
    column1 not in()
    and 
    column2 not in()
    and 
    column3 not in()
    --越不让用越用
      

  3.   

    我说的有问题,应该是有两张表,结构都一样,但是A表中的记录包含了B表中的记录,想求A表中去除了B的那部分记录的数据,该怎么写?
      

  4.   


    SELECT * FROM TABLE1 A WHERE NOT EXISTS (SELECT 1 FROM TABLE2 B WHERE A.FIELD1=B.FIELD1 AND A.FIELD2=B.FIELD2 AND A.FIELD3=B.FIELD3)
      

  5.   

    我是这样写的,大家看有没错
    select * from A where not (A.字段1 in(select B.字段1 from B) and A.字段2 in(select B.字段2 from B) and A.字段3 in(select B.字段3 from B) and A.字段xx = 0) ...
      

  6.   

    select * from A  
    EXCEPT  
    select * from B