怎样找出表B中不同于表A中的所有记录?

解决方案 »

  1.   

    select * from b where id not in (select * from a)
    --注:id 为主键
      

  2.   

    假定A表和B表都有name这个字段,下面的SQL语句将选出所有在A表中出现而没有在B表中出现的记录select * from A where name not in(select name from b)
      

  3.   

    select id,name from Table1 where id not in (select id from Table2)
    id是不是主键都可以这样用
      

  4.   

    不要用not in或not exists 我刚答过这个问题http://community.csdn.net/Expert/topic/3638/3638342.xml?temp=.814541