×

sql · level 2 · unit 4 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

checks a value against a whole list.

WHERE kind = 'fruit' OR kind = 'sweet' works, but it grows long fast. WHERE kind IN ('fruit', 'sweet') says the same thing: keep the row if its kind matches any item in the brackets.

The list goes in brackets, with commas between the items. Text keeps its single quotes and numbers do not, like WHERE age IN (1, 3, 5).

flips it, keeping only the rows whose value matches nothing in the list.

SELECT name, kind FROM snacks
WHERE kind IN ('fruit', 'sweet')
ORDER BY name;

If the list holds a NULL, NOT IN matches nothing at all, so keep NULL out of the list.