QuestionQ5

VerifiedDisplaying Data from Multiple Tables

Evaluate the following SQL statement:

SELECT e.emp_name, d.dept_name  
FROM employees e  
JOIN departments d  
USING (department_id)  
WHERE d.department_id NOT IN (10, 40)  
ORDER BY dept_name;  

The statement fails on execution. Which change corrects the error?

Explanation

Oracle does not allow an explicitly qualified reference to a column that is part of a named join using USING. Because department_id is the USING column, the predicate must reference it as department_id, without the d. alias. Oracle documents this as ORA-25154, “column part of USING clause cannot have qualifier.”

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!