次の値を持つ2つのテーブルがあります。
tab1 tab2
---- ----
A A
B E
C F
D G
出力は次のようになります。
O/P
---
B
C
D
E
F
G
次の値を持つ2つのテーブルがあります。
tab1 tab2
---- ----
A A
B E
C F
D G
出力は次のようになります。
O/P
---
B
C
D
E
F
G
select field from tab1
union all
select field from tab2
minus
(select field from tab1
intersect
select field from tab2
);
また :)
select field from tab1
minus
select field from tab2
union all
select field from tab2
minus
select field from tab1
しかし、BEST(パフォーマンスの場合:) ) :
select distinct nvl(a.field, b.field) as field
from tab1 a
full join tab2 b on (a.field=b.field)
where a.field is null or b.field is null;
上記のクエリのテストを参照してください。
select field from tab1 where field not in (select field from tab2)
union
select field from tab2 where field not in (select field from tab1)