Bird
0
0

Which of the following SQL statements correctly joins three tables X, Y, and Z where X.key = Y.x_key and Y.key = Z.y_key?

easy📝 Syntax Q3 of 15
SQL - Advanced Joins
Which of the following SQL statements correctly joins three tables X, Y, and Z where X.key = Y.x_key and Y.key = Z.y_key?
ASELECT * FROM X JOIN Y ON X.key = Y.x_key JOIN Z ON Y.key = Z.y_key;
BSELECT * FROM X JOIN Y ON X.key = Y.key JOIN Z ON Y.key = Z.key;
CSELECT * FROM X JOIN Y ON X.key = Y.x_key JOIN Z ON X.key = Z.y_key;
DSELECT * FROM X, Y, Z WHERE X.key = Y.key AND Y.key = Z.key;
Step-by-Step Solution
Solution:
  1. Step 1: Understand join conditions

    The join conditions are X.key = Y.x_key and Y.key = Z.y_key.
  2. Step 2: Match conditions in JOIN clauses

    SELECT * FROM X JOIN Y ON X.key = Y.x_key JOIN Z ON Y.key = Z.y_key; correctly uses JOIN Y ON X.key = Y.x_key and JOIN Z ON Y.key = Z.y_key.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Verify join keys match the conditions exactly [OK]
Quick Trick: Match join conditions exactly in ON clauses [OK]
Common Mistakes:
MISTAKES
  • Using incorrect join keys
  • Joining tables without proper ON conditions
  • Confusing column names in join conditions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes