Bird
0
0

Which of the following is the correct syntax to join two tables Employees and Departments on the column DeptID?

easy📝 Syntax Q12 of 15
SQL - INNER JOIN
Which of the following is the correct syntax to join two tables Employees and Departments on the column DeptID?
ASELECT * FROM Employees JOIN Departments WHERE Employees.DeptID = Departments.DeptID;
BSELECT * FROM Employees JOIN Departments USING Employees.DeptID;
CSELECT * FROM Employees, Departments ON Employees.DeptID = Departments.DeptID;
DSELECT * FROM Employees JOIN Departments ON Employees.DeptID = Departments.DeptID;
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct JOIN syntax

    The correct JOIN syntax uses JOIN ... ON ... to specify the matching condition.
  2. Step 2: Check each option

    SELECT * FROM Employees JOIN Departments ON Employees.DeptID = Departments.DeptID; uses JOIN ... ON correctly. SELECT * FROM Employees JOIN Departments WHERE Employees.DeptID = Departments.DeptID; wrongly uses WHERE instead of ON. SELECT * FROM Employees, Departments ON Employees.DeptID = Departments.DeptID; misuses ON with comma join. SELECT * FROM Employees JOIN Departments USING Employees.DeptID; misuses USING syntax with table prefix.
  3. Final Answer:

    SELECT * FROM Employees JOIN Departments ON Employees.DeptID = Departments.DeptID; -> Option D
  4. Quick Check:

    JOIN syntax requires ON condition [OK]
Quick Trick: JOIN needs ON, not WHERE or comma with ON [OK]
Common Mistakes:
MISTAKES
  • Using WHERE instead of ON for join condition
  • Mixing comma joins with ON clause
  • Incorrect USING syntax with table prefixes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes