Bird
0
0

Given two tables:

medium📝 query result Q13 of 15
SQL - Advanced Joins
Given two tables:
Colors with rows: Red, Blue
Shapes with rows: Circle, Square, Triangle
What will be the result of:
SELECT Colors.color, Shapes.shape FROM Colors CROSS JOIN Shapes;
A[('Red', 'Circle'), ('Red', 'Square'), ('Red', 'Triangle'), ('Blue', 'Circle'), ('Blue', 'Square'), ('Blue', 'Triangle')]
B[('Red', 'Circle'), ('Blue', 'Square'), ('Red', 'Triangle')]
C[('Red', 'Circle'), ('Blue', 'Circle'), ('Red', 'Square'), ('Blue', 'Square')]
DEmpty result set
Step-by-Step Solution
Solution:
  1. Step 1: Count rows in each table

    Colors has 2 rows, Shapes has 3 rows.
  2. Step 2: Calculate CROSS JOIN result

    CROSS JOIN returns all pairs: 2 * 3 = 6 rows combining each color with each shape.
  3. Final Answer:

    [('Red', 'Circle'), ('Red', 'Square'), ('Red', 'Triangle'), ('Blue', 'Circle'), ('Blue', 'Square'), ('Blue', 'Triangle')] -> Option A
  4. Quick Check:

    2 colors * 3 shapes = 6 pairs [OK]
Quick Trick: Multiply row counts for CROSS JOIN result size [OK]
Common Mistakes:
MISTAKES
  • Listing only matching pairs instead of all combinations
  • Confusing CROSS JOIN with INNER JOIN
  • Ignoring total number of rows in result

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes