1

次の値を持つ2つのテーブルがあります。

tab1              tab2
----              ----
A                   A
B                   E
C                   F
D                   G

出力は次のようになります。

O/P
---
B
C
D
E
F
G
4

2 に答える 2

4
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;

上記のクエリのテストを参照してください。

于 2013-05-22T13:59:40.373 に答える
1
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)
于 2013-05-22T13:34:04.417 に答える