Consider the following 'CONSOLES' and 'COST' table:
CONSOLES
ProID Name Color 1 XBOX Black 2 PS5 White 3 SteamMachine Black
COST
ProID Space Price 1 512GB 499 1 1TB 599 2 512GB 499 2 1TB 599
Which of the query will result in the following output?
ProID Name Color Space Price 1 XBOX Black 512GB 499 1 XBOX Black 1TB 599 2 PS5 White 512GB 499 2 PS5 White 1TB 599
Consider the following 'CONSOLES' and 'COST' table:
CONSOLES
| ProID | Name | Color |
|---|---|---|
| 1 | XBOX | Black |
| 2 | PS5 | White |
| 3 | SteamMachine | Black |
COST
| ProID | Space | Price |
|---|---|---|
| 1 | 512GB | 499 |
| 1 | 1TB | 599 |
| 2 | 512GB | 499 |
| 2 | 1TB | 599 |
Which of the query will result in the following output?
| ProID | Name | Color | Space | Price |
|---|---|---|---|---|
| 1 | XBOX | Black | 512GB | 499 |
| 1 | XBOX | Black | 1TB | 599 |
| 2 | PS5 | White | 512GB | 499 |
| 2 | PS5 | White | 1TB | 599 |
Solution
A NATURAL JOIN joins the two tables on all columns with the same name, here ProID, and shows that column only once. It keeps only matching rows, so SteamMachine (ProID 3), which has no entry in COST, is dropped. The result has the columns ProID, Name, Color, Space, Price, with 4 rows, exactly as shown.
Options 1 and 4: an outer join (LEFT or full) keeps unmatched rows from CONSOLE, so SteamMachine would appear with NULL Space and Price. With SELECT * it would also show ProID twice, since the join uses ON rather than natural matching.
Option 2: UNION combines the rows of two queries and does not accept an ON condition, so it is not a join.
Related questions:
2025: 3 June Shift 2
2025: 30 May Shift 2
2026: 11 May Shift 2