Forklar venligst, hvordan du finder den højre og venstre ydre sammenføjning korrekt med et eksempel
Jeg vil prøve at vise forskellen mellem Oracle outer join-syntaks og ANSI/ISO-syntaksen .
VENSTRE YDRE JOIN -
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);
HØJRE YDRE JOIN -
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);
FULD YDRE JOIN -
Før den oprindelige understøttelse af hash fuld outerjoin i 11gR1, ville Oracle internt konvertere FULL OUTER JOIN på følgende måde -
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);
Tag et kig på dette.