Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1INNER JOIN Teams ON Players.team_id = Teams.team_id | AThe matching condition: the foreign key in Players must equal the primary key in Teams | |
| 2Players.team_id = Teams.team_id | BOrders.customer_id = Customers.customer_id | |
| 3Show student names with the name of their class by joining two tables on a matching key | CThe field names have no table names in front, so it is unclear which class_id belongs to which table. Use Students.class_id = Classes.class_id. | |
| 4Write table.field names so SQL knows which table a field belongs to when both tables share the same field name | DThe ON condition is missing, so SQL does not know which fields to match. It should end with ON Students.class_id = Classes.class_id. | |
| 5SELECT * FROM Students INNER JOIN Classes; | ESELECT Students.name, Classes.class_name FROM Students INNER JOIN Classes ON Students.class_id = Classes.class_id; | |
| 6SELECT * FROM Students INNER JOIN Classes ON class_id = class_id; | FCombines each player row with the team row that has a matching team_id, so both sets of data appear together |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
INNER JOIN t2 ON t1.key = t2.key — Combines rows from two tables where a foreign key matches a primary key, so related data shows in one result. Use table.field names to say which table each field belongs to.SELECT pet.name, owner.name
FROM pet
INNER JOIN owner ON pet.ownerid = owner.id;SELECT pet.name, owner.name
FROM pet
INNER JOIN owner ON pet.ownerid = owner.id;SELECT pet.name, owner.name
FROM pet
INNER JOIN owner ON pet.ownerid = owner.id;SELECT pet.name, owner.name
FROM pet
INNER JOIN owner ON pet.ownerid = owner.id;SELECT pet.name, owner.name
FROM pet
INNER JOIN owner ON pet.ownerid = owner.id;