16

FULL OUTER JOIN や FULL JOIN などのキーワードを使用する代わりに、'+' 演算子を使用して 'where' 句を使用して完全な外部結合を実行するにはどうすればよいですか?!

4

2 に答える 2

22

できません(少なくとも直接)。Oracle は、SQL:1999 構文を使用した完全外部結合のみをサポートしています。

2 つの外部結合を結合することで偽装できます。

select a.field1, b.field2
from table_a a, table_b b
where a.id = b.id(+)
union all 
select a.field1, b.field2
from table_a a, table b b
where a.id(+) = b.id
      and a.id is null

SQL:1999 構文を使用すると、はるかに読みやすくなります。

select a.field1, b.field2
from table_a a full outer join table_b b
on a.id = b.id
于 2012-05-08T13:59:47.603 に答える
3

オラクルで実行して、自分でも結果を確認できる例を次に示します。

with 
a as 
   (select 'A' tbl, level id from dual connect by level < 1000),
b as 
   (select 'B' tbl, level + 500 id from dual connect by level < 1000)
select a.tbl, a.id, b.tbl, b.id from a, b where a.id = b.id(+)
union all
select a.tbl, a.id, b.tbl, b.id from a, b where a.id(+) = b.id and a.id is null

以下と同じです:

with 
a as 
   (select 'A' tbl, level id from dual connect by level < 1000),
b as 
   (select 'B' tbl, level + 500 id from dual connect by level < 1000)
select a.tbl, a.id, b.tbl, b.id from a full outer join b on a.id = b.id
于 2012-05-08T15:09:50.120 に答える