请顺便把能实现上述功能的所有SQL语句写法写出来
谢谢。

解决方案 »

  1.   

    奇怪的是in和exists是可以查出表A中ID在表B中存在的记录的
      

  2.   

    你的例子的写法应该是select * from A where id not in (select id from B where A.id = B.id)
                        select * from A where not exists (select id from B where A.id = B.id)
      

  3.   

    第一条语句没看出有问题。SQL> select * from a where id not in(select id from b);ID         NAME
    ---------- ----------
    6          dd
    7          eeSQL> select * from a where not exists(select 1 from b where b.id=a.id);ID         NAME
    ---------- ----------
    6          dd
    7          eeSQL>
      

  4.   

    如果a,b的表结构相同的话才可以这样写
    select * from A where not exists (select * from B)