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 | |
|---|---|---|
| 1WHERE studentId IN (SELECT studentId FROM results) | AKeeps only the students whose studentId appears in the results table | |
| 2WHERE studentId NOT IN (SELECT studentId FROM orders) | BSELECT firstName FROM students WHERE studentId IN (SELECT studentId FROM results WHERE mark > 80); | |
| 3A sub-query is a SELECT written inside brackets within the WHERE clause of another query | CKeeps only the students who have never placed an order | |
| 4A sub-query can do the same job as a join: finding students linked to rows in another table | DThe sub-query is missing its brackets. It must be written as IN (SELECT studentId FROM results). | |
| 5SELECT firstName FROM students WHERE studentId IN SELECT studentId FROM results; | EThe sub-query returns the wrong column. IN compares studentId values, so the sub-query must select studentId, not firstName (which is not even in results). | |
| 6SELECT firstName FROM students WHERE studentId IN (SELECT firstName FROM results); | FSELECT firstName FROM students WHERE studentId IN (SELECT studentId FROM orders); |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
IN (SELECT studentId FROM results) — A sub-query is a SELECT inside brackets in a WHERE clause. It returns a list of values, and IN keeps only the rows whose value is in that list. NOT IN keeps the rows that are not in it.SELECT firstName FROM students
WHERE studentId IN
(SELECT studentId FROM results);SELECT firstName FROM students
WHERE studentId IN
(SELECT studentId FROM results);SELECT name FROM products
WHERE productId NOT IN
(SELECT productId FROM orders);SELECT firstName FROM students
WHERE studentId IN
(SELECT studentId FROM results);SELECT name FROM subjects
WHERE subjectId IN
(SELECT subjectId FROM results);