Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, Become a SELECT Star!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
read the transcript!

WHERE filters the table you start with. For example, let’s break down this query that finds all owners with cats named “daisy”

SELECT owner
FROM cats
WHERE name = 'daisy' 

FROM cats is pulling from a database with tables of cats and people.

owner name
1 daisy
1 dragonsnap
3 buttercup
4 rose

WHERE name = 'daisy'

owner name
1 daisy

SELECT owner

owner
1

What you can put in a WHERE :

expr LIKE…`

Check if a string contains a substring! WHERE name LIKE '%darcy%'

(% is a wildcard, like * in your shell)

exprIN (...)

Check if an expression is in a fist of values WHERE name IN ('bella', 'simba')

=, !=, <, >=

these work the way you’d guess, except when NULL is involved.

WHERE revenue - costs >=0

expr IS NULL, expr- IS NOT NULL

more about NULL on pages 15-17

= NULL (crossed out)
IS NULL (circled)

AND, OR, NOT

You can AND together as many conditions as you want

tiny little illustration of a smiling stick figure with curly hair: If I’m using lots of ANDs, like to write them like this:

(....)
AND (....)
AND (....)

(put all the ORs in the parentheses)

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)