select * from a where f1 not in (select f1 from b)

解决方案 »

  1.   

    agree with newly_ignorant
    so easy :)
      

  2.   

    http://www.csdn.net/expert/topic/1017/1017058.xml?temp=.5201837
      

  3.   

    agree with newly_ignorant(不学无术)
      

  4.   

    agree with newly_ignorant
    so easy :)
      

  5.   

    select * from a where not exists (select f1 from b where a.f1 = b.f1)
      

  6.   

    写个难点的,在执行效率上不知哪一个更好select a.* from a inner join b on a.fl<>b.f1
      

  7.   

    select a.* from a 
    where not exists (select b.f1 from b where a.f1=b.f1)
      

  8.   

    select * from a where f1 not in (select f1 from b)
      

  9.   

    如果在a,b中f1不是唯一主键的话不能用select a.* from a inner join b on a.fl<>b.f1,如果f1允许为空的话不能select * from a where f1 not in (select f1 from b)语名,这样如果a中f1为空是将得不到你想要的结果,此时可以改用select * from a where f1 not in (select f1 from b) or f1 is null
      

  10.   

    select * from a where f1 not in (select f1 from b) 或
    select * from a where  not exist (select * from b where b.f1=a.fi)
    前提是f1是两表中的唯一关键字,却不为null: