Tolong jelaskan cara mencari join luar kanan dan kiri yang benar beserta contohnya
Saya akan mencoba menunjukkan perbedaan antara Sintaksis gabungan luar Oracle dan Sintaks ANSI/ISO .
KIRI LUAR GABUNG -
SELECT e.last_name,
d.department_name
FROM employees e,
departments d
WHERE e.department_id = d.department_id(+);
SELECT e.last_name,
d.department_name
FROM employees e
LEFT OUTER JOIN departments d
ON (e.department_id = d.department_id);
GABUNG LUAR KANAN -
SELECT e.last_name,
d.department_name
FROM employees e,
departments d
WHERE e.department_id(+) = d.department_id;
SELECT e.last_name,
d.department_name
FROM employees e
RIGHT OUTER JOIN departments d
ON (e.department_id = d.department_id);
GABUNG LUAR PENUH -
Sebelum dukungan asli hash full outerjoin di 11gR1, Oracle akan secara internal mengonversi FULL OUTER JOIN dengan cara berikut -
SELECT e.last_name,
d.department_name
FROM employees e,
departments d
WHERE e.department_id = d.department_id(+)
UNION ALL
SELECT NULL,
d.department_name
FROM departments d
WHERE NOT EXISTS
(SELECT 1 FROM employees e WHERE e.department_id = d.department_id
);
SELECT e.last_name,
d.department_name
FROM employees e
FULL OUTER JOIN departments d
ON (e.department_id = d.department_id);
Lihat ini.