Bird
0
0

You have two tables:

easy📝 Application Q15 of 15
PostgreSQL - Joins in PostgreSQL
You have two tables:
Colors:
color_id | color_name
1 | Red
2 | Blue

Shapes:
shape_id | shape_name
1 | Circle
2 | Square
3 | Triangle

How many rows will this query return?
SELECT color_name, shape_name FROM Colors CROSS JOIN Shapes;
A5
B3
C2
D6
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 size

    Result rows = 2 x 3 = 6 rows, all combinations of colors and shapes.
  3. Final Answer:

    6 -> Option D
  4. Quick Check:

    2 x 3 = 6 rows [OK]
Quick Trick: Multiply row counts of both tables for CROSS JOIN size [OK]
Common Mistakes:
  • Adding rows instead of multiplying
  • Ignoring one table's row count
  • Confusing CROSS JOIN with INNER JOIN

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes