Question 1
The `EMPLOYEES` and `DEPARTMENTS` tables have exactly one column name in common: `DEPT_ID`. `LAST_NAME` exists only in `EMPLOYEES`, and `DEPT_NAME` and `LOCATION` only in `DEPARTMENTS`. Which query executes successfully and lists the last name of every employee assigned to department 20 together with that department's name, returning exactly one row per such employee?
A. SELECT e.last_name, d.dept_name FROM employees e NATURAL JOIN departments d WHERE d.dept_id = 20
Assumes a table alias may be used on a NATURAL JOIN's common column. After NATURAL JOIN, DEPT_ID becomes a single coalesced column that must be referenced without any qualifier anywhere in the statement, so `d.dept_id` in the WHERE clause raises ORA-25155 (column used in NATURAL join cannot have qualifier).
B. SELECT e.last_name, d.dept_name FROM employees e, departments d WHERE e.dept_id = 20
Treats a filter on one table as if it were also the join condition. The comma join supplies no equijoin predicate, so every department row is paired with every qualifying employee row — a Cartesian product that repeats each employee once per department instead of one row per employee.
C. SELECT last_name, dept_name FROM employees JOIN departments USING (dept_id) WHERE dept_id = 20Correct answer
USING (dept_id) equijoins on the shared column and coalesces it into one unqualified column that is legal to reference bare in the WHERE clause; LAST_NAME and DEPT_NAME are unique to one table each, so the unqualified select list is unambiguous. One row per matching employee is returned.
D. SELECT e.last_name, d.dept_name FROM employees e JOIN departments d USING (dept_id) WHERE e.dept_id = 20
Assumes a USING column can still be qualified by the table it came from. A column named in USING has no table prefix anywhere in the query, so `e.dept_id` raises ORA-25154 (column part of USING clause cannot have qualifier), even though the same predicate written unqualified would be valid.
Explanation
Both USING and NATURAL JOIN merge the shared column into a single coalesced join column, and that column must then be referenced without a table name or alias anywhere in the statement — select list, WHERE clause, or ORDER BY — otherwise Oracle rejects the statement. Columns that are not part of the join key are unaffected and may be qualified freely. A comma join, by contrast, coalesces nothing and joins nothing unless an explicit equijoin predicate is written, so omitting it yields a Cartesian product rather than a filtered inner join.