你的例子的写法应该是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)
第一条语句没看出有问题。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>
如果a,b的表结构相同的话才可以这样写 select * from A where not exists (select * from B)
select * from A where not exists (select id from B where A.id = B.id)
---------- ----------
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>
select * from A where not exists (select * from B)