Bird
0
0

Consider this query:

medium📝 Debug Q14 of 15
SQL - INNER JOIN
Consider this query:
SELECT e.Name, d.DeptName FROM Employees e INNER JOIN Departments d ON e.DeptID = d.ID;

Given Departments has column DeptID but no ID column, what is the issue?
AThe query will join on wrong columns but still return rows.
BThe query will run but return no rows.
CThe query will cause a syntax error due to wrong column name.
DThe query will join correctly because aliases fix column names.
Step-by-Step Solution
Solution:
  1. Step 1: Check column names in ON condition

    The query uses d.ID but Departments table has DeptID, not ID.
  2. Step 2: Understand SQL error on invalid column

    Referencing a non-existent column causes a syntax or runtime error.
  3. Final Answer:

    The query will cause a syntax error due to wrong column name. -> Option C
  4. Quick Check:

    Wrong column in ON causes error [OK]
Quick Trick: Verify column names in ON condition to avoid errors [OK]
Common Mistakes:
MISTAKES
  • Assuming aliases rename columns automatically
  • Using wrong column names in ON clause
  • Expecting empty result instead of error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes