sql · level 1 · unit 2 · lesson 4
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
Ask sharper questions with , and .
AND links two conditions. A row stays only if it passes both, like a snack that is sweet and under a pound.
OR keeps a row that passes at least one condition, like a pet that is a cat or a dog. NOT flips a condition, so NOT species = 'dog' keeps everything except dogs.
Each side needs a full condition: species = 'cat' OR species = 'dog'. Write the column name both times.
SELECT name, price FROM snacks WHERE kind = 'sweet' AND price < 100; NOT species = 'dog' finds the same rows as species <> 'dog'.
guess first
Old or fishy? Guess what comes back.
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
SELECT name FROM pets WHERE age > 4 OR species = 'fish';
your turn
Your turn. Find a snack that fits your plan.
Pick a kind of snack (sweet, savoury or fruit) and the most you will pay, in pence. The query finds snacks that pass both tests, so make sure at least one fits.
result
Your answer appears here as a table.
fix it
Where have the dogs gone? Can you fix it?
result
Your answer appears here as a table.
- The cats are there but the dogs are missing. Look at the right side of
OR. 'dog'on its own is not a condition. It never says which column to check.- Write the column name again: species = 'cat' OR species = 'dog', then press run.
nailed it
you asked sharper questions. :D
ANDneeds both conditions to pass.ORneeds at least one.NOTflips a condition.- Write a full condition on each side of
ANDorOR.
new words in your collection
- AND
- OR
- NOT
This lesson isn’t saved. A free account remembers every lesson you finish.