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 | |
|---|---|---|
| 1SELECT members.name, loans.title FROM members JOIN loans ON members.memberId = loans.memberId; | AON loans.memberId = members.memberId | |
| 2SELECT classes.className, teachers.name FROM classes JOIN teachers ON classes.teacherId = teachers.teacherId ORDER BY classes.className; | BWHERE members.name = 'Ava Nguyen' | |
| 3Follow the keys: join the two tables where the foreign key equals the primary key shown on the ERD relationship line. | CLists each member's name beside the titles of the loans they have, by matching the key in both tables. | |
| 4After joining the tables, add WHERE to keep only the rows the question asks for, such as one member's loans. | DThe ON condition is missing, so every member is paired with every loan and the results include loans that member never borrowed. | |
| 5SELECT members.name, loans.title FROM members JOIN loans; | EThe join compares the wrong fields: classId is the primary key of classes, not the foreign key that points to teachers. | |
| 6FROM classes JOIN teachers ON classes.classId = teachers.teacherId | FLists every class with its teacher's name, sorted by class name. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
multi-table query — A query that gets fields from more than one table: find which tables hold them, JOIN them on matching keys, then add WHERE and ORDER BY to match the question.SELECT members.name, loans.title
FROM members JOIN loans
ON members.id = loans.memberId;SELECT classes.className, teachers.name
FROM classes JOIN teachers
ON classes.teacherId = teachers.id;SELECT m.name, l.title FROM members m
JOIN loans l ON m.id = l.memberId
WHERE l.returned = 'No' ORDER BY m.name;SELECT c.className, t.name FROM classes c
JOIN teachers t ON c.teacherId = t.id
WHERE c.yearLevel = 9 ORDER BY t.name;SELECT classes.className, teachers.name
FROM classes JOIN teachers
ON classes.teacherId = teachers.id;