Bird
0
0

Which of the following is the correct syntax to perform a LEFT JOIN between tables employees and departments on employees.dept_id = departments.id?

easy📝 Syntax Q12 of 15
SQL - Advanced Joins
Which of the following is the correct syntax to perform a LEFT JOIN between tables employees and departments on employees.dept_id = departments.id?
ASELECT * FROM employees JOIN departments ON employees.dept_id = departments.id LEFT;
BSELECT * FROM employees JOIN departments WHERE employees.dept_id = departments.id LEFT;
CSELECT * FROM employees LEFT JOIN departments WHERE employees.dept_id = departments.id;
DSELECT * FROM employees LEFT JOIN departments ON employees.dept_id = departments.id;
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct JOIN syntax

    The correct syntax for LEFT JOIN uses the ON keyword to specify join condition: LEFT JOIN table ON condition.
  2. Step 2: Check each option

    SELECT * FROM employees LEFT JOIN departments ON employees.dept_id = departments.id; uses correct syntax. Options B and D misuse WHERE or place LEFT incorrectly. SELECT * FROM employees LEFT JOIN departments WHERE employees.dept_id = departments.id; uses WHERE instead of ON.
  3. Final Answer:

    SELECT * FROM employees LEFT JOIN departments ON employees.dept_id = departments.id; -> Option D
  4. Quick Check:

    LEFT JOIN requires ON, not WHERE [OK]
Quick Trick: Use ON for join condition, not WHERE in JOIN syntax [OK]
Common Mistakes:
MISTAKES
  • Using WHERE instead of ON for join condition
  • Placing LEFT keyword after JOIN incorrectly
  • Omitting ON clause in JOIN

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes