Which query would you use?

Click the Exhibit button and examine the data in the EMPLOYEES and DEPARTMENTS tables.

You want to retrieve all employees, whether or not they have matching departments in the
departments table. Which query would you use?

Click the Exhibit button and examine the data in the EMPLOYEES and DEPARTMENTS tables.

You want to retrieve all employees, whether or not they have matching departments in the
departments table. Which query would you use?

A.
SELECT last_name, department_name
FROM employees NATURAL JOIN departments;

B.
SELECT last_name, department_name
FROM employees e JOIN departments d
ON (e.department_id = d.department_id);

C.
SELECT last_name, department_name
FROM employees JOIN departments ;

D.
SELECT last_name, department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);

E.
SELECT last_name, department_name
FROM employees e LEFT OUTER
JOIN departments d ON (e.department_id = d.department_id);

F.
SELECT last_name, department_name
FROM employees FULL JOIN departments
ON (e.department_id = d.department_id);

Explanation:

Answer F is correct. This query shows correct syntax to retrieve all employees, whether or not
they have matching departments in the department table. Oracle9i extends its compliance with
ANSI/ISO by supporting that standard’s requirements for outer join syntax and semantics.
OCP Introduction to Oracle 9i: SQL Exam Guide , Jason Couchman, p. 112-114
Chapter 3: Advanced Data Selection in Oracle



Leave a Reply 0

Your email address will not be published. Required fields are marked *