Exam-style question
Try this first
A database has an Order table with CustomerID and an Item table with ItemID and Description. The Order table also contains ItemID. Write an SQL statement that retrieves each OrderID and the corresponding item Description by joining the tables. Explain how the tables are matched.
Answer and explanation
Concise answer
SELECT Order.OrderID, Item.Description FROM Order JOIN Item ON Order.ItemID = Item.ItemID;
Why this is correct
The statement retrieves OrderID from Order and Description from Item. JOIN combines rows from the two tables, and the ON clause matches rows where the ItemID in Order equals the ItemID in Item.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
