--建立测试表1
create table test1
(id number);
--建立测试表1
create table test2
(id number);
--插入测试数据
insert into test1 values(1);
insert into test1 values(2);
insert into test1 values(3);
insert into test1 values(4);
--插入测试数据
insert into test2 values(1);
insert into test2 values(2);
insert into test2 values(5);
insert into test2 values(6);
--执行语句,察看结果
select id
from test1
union
select id
from test2
minus
select a.id
from test1 a,test2 b
where a.id = b.id;
select *
from table1
where table1.a not in (select table2.b from table2)
union all
select *
from table2
where table2.b not in (select table1.a from table1)