반응형
'+' 연산자를 사용하여 Oracle에서 FULL OUTER JOIN을 수행하는 방법은 무엇입니까?
FULL OUTER JOIN 또는 FULL JOIN과 같은 키워드를 사용하는 대신 '+' 연산자의 도움을 받아 'where' 절을 사용하여 Full Outer Join을 수행하려면 어떻게 해야 합니까?!
당신은 (적어도 직접적으로는) 할 수 없습니다.Oracle은 SQL:1999 구문을 사용하는 전체 외부 조인만 지원합니다.
두 개의 외부 조인을 결합하여 가짜로 만들 수 있습니다.
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
다음은 오라클에서 실행하여 결과를 직접 확인할 수 있는 예제입니다.
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
언급URL : https://stackoverflow.com/questions/10500020/how-to-perform-full-outer-join-in-oracle-using-operator
반응형
'programing' 카테고리의 다른 글
UIPageView 컨트롤러의 스와이프 제스처를 비활성화하려면 어떻게 해야 합니까? (0) | 2023.06.27 |
---|---|
Java를 통해 MongoDB에 여러 문서를 한 번에 삽입하는 방법 (0) | 2023.06.27 |
문자열 형식의 %s과 %d의 차이점은 무엇입니까? (0) | 2023.06.27 |
@ngrx/Store를 업그레이드할 때 '작업' 유형에 'payload' 속성이 없습니다. (0) | 2023.06.27 |
함수 및 Firestore 사용 시 필드 값이 정의되지 않음 (0) | 2023.06.27 |