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 (house = 'Red' OR house = 'Blue') AND yearLevel = 7 | AAND is used between two values of the same field. A record cannot be in two houses at once, so no rows are returned. It should be (house = 'Red' OR house = 'Blue'). | |
| 2WHERE house = 'Red' OR (house = 'Blue' AND yearLevel = 7) | BWHERE (yearLevel = 7 OR yearLevel = 8) AND points > 100 | |
| 3Brackets round an OR on the same field mean a record must match one of those two values and also meet the extra AND condition. | CReturns every Red house student, plus only the Year 7 students from Blue house. | |
| 4Brackets round an AND mean those two conditions are checked together, so a record can also qualify by meeting the single condition on the other side of the OR. | DThe brackets are missing. AND is worked out before OR, so all Year 7 students are returned whatever their house. The query should be WHERE (yearLevel = 7 OR yearLevel = 8) AND house = 'Red'. | |
| 5WHERE yearLevel = 7 OR yearLevel = 8 AND house = 'Red' | EWHERE points > 100 OR (house = 'Red' AND yearLevel = 7) | |
| 6WHERE (house = 'Red' AND house = 'Blue') AND yearLevel = 7 | FReturns only Year 7 students who are in Red house or Blue house. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
WHERE (A OR B) AND C — Brackets make SQL work out the OR first, then the AND. A record must meet C and also A or B. Moving the brackets, as in A OR (B AND C), can return different records.SELECT firstName FROM students
WHERE (house = 'Red' OR house = 'Blue')
AND yearLevel = 7;SELECT firstName FROM students
WHERE (house = 'Red' OR house = 'Blue')
AND yearLevel = 7;SELECT firstName FROM students
WHERE house = 'Red'
OR (house = 'Blue' AND yearLevel = 8);SELECT name FROM products
WHERE (category = 'Tech' OR category =
'Sport')
AND stock > 0;SELECT firstName FROM students
WHERE (yearLevel = 7 AND house = 'Red')
OR points > 100;