Bird
0
0

Which of the following SQL statements correctly performs a LEFT JOIN between Orders and Customers on Orders.customer_id = Customers.id?

easy📝 Syntax Q3 of 15
SQL - LEFT and RIGHT JOIN
Which of the following SQL statements correctly performs a LEFT JOIN between Orders and Customers on Orders.customer_id = Customers.id?
ASELECT * FROM Orders LEFT JOIN Customers ON Orders.customer_id = Customers.id;
BSELECT * FROM Customers LEFT JOIN Orders ON Orders.customer_id = Customers.id;
CSELECT * FROM Orders INNER JOIN Customers ON Orders.customer_id = Customers.id;
DSELECT * FROM Customers INNER JOIN Orders ON Orders.customer_id = Customers.id;
Step-by-Step Solution
Solution:
  1. Step 1: Identify left table

    The LEFT JOIN preserves all rows from the left table, which is the first table in the FROM clause.
  2. Step 2: Match join condition

    The ON clause must correctly relate Orders.customer_id to Customers.id.
  3. Final Answer:

    SELECT * FROM Orders LEFT JOIN Customers ON Orders.customer_id = Customers.id; -> Option A
  4. Quick Check:

    LEFT JOIN keeps all Orders rows [OK]
Quick Trick: LEFT JOIN keeps all rows from first table in FROM [OK]
Common Mistakes:
MISTAKES
  • Swapping left and right tables
  • Using INNER JOIN instead of LEFT JOIN
  • Incorrect ON clause columns

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes