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 | |
|---|---|---|
| 1students.firstName | AThe ON condition uses studentId on both sides without a table name, so it is ambiguous. It should be students.studentId = results.studentId. | |
| 2SELECT students.firstName, results.mark | BNames the students table as the source of the firstName field, so there is no doubt which table it comes from. | |
| 3Both students and results have a studentId field, so the join must say which one it means or SQL gives an ambiguous column error. | CstudentId is in both tables but is not qualified in the SELECT, so SQL gives an ambiguous column error. It should be students.studentId. | |
| 4Qualifying the fields on both sides of the ON condition names the table for each side of the match. | DSELECT students.studentId, results.mark FROM students JOIN results ON students.studentId = results.studentId; | |
| 5SELECT studentId, mark FROM students JOIN results ON students.studentId = results.studentId; | EON orders.productId = products.productId | |
| 6SELECT students.firstName, results.mark FROM students JOIN results ON studentId = studentId; | FSelects one field from each of two tables, with each field qualified by its own table name. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
table.field — Names the table a field comes from, like students.name. Needed in a join when both tables share a field name, or SQL gives an ambiguous column error.SELECT students.name, classes.room
FROM students JOIN classes
ON students.classId = classes.classId;SELECT students.name, classes.room
FROM students JOIN classes
ON students.classId = classes.classId;SELECT students.name, classes.room
FROM students JOIN classes
ON students.classId = classes.classId;SELECT students.classId, classes.room
FROM students JOIN classes
ON students.classId = classes.classId;SELECT students.firstName, results.mark
FROM students JOIN results
ON students.studentId = results.studentId;