The register of residents at the village office: write SELECT, WHERE, ORDER BY and LIMIT yourself, and a real SQLite answers step by step. What does = NULL…
Why it matters
SQL is everywhere (backends, data, analytics). Knowing that the run order differs from the written order explains why an alias cannot go in WHERE (in MySQL and PostgreSQL), why LIMIT without ORDER BY gives arbitrary rows, and why = NULL never finds anything.
The key idea
SQL is declarative, and it runs in a different order than it is written
Common mistakes
Using == or double quotes Standard SQL compares with a single =, and text goes in single quotes: nama = 'Bu Sari'. SQLite forgives ==, and reads "x" as text when no column is called x; MySQL refuses ==, PostgreSQL always reads "x" as a column name.
A SELECT alias in WHERE WHERE runs before SELECT, so in MySQL and PostgreSQL the alias does not exist there yet: repeat the expression (WHERE umur >= 60), or use the alias in ORDER BY, which runs after. SQLite accepts it as an extra, so a query that runs in SQLite can fail in MySQL.
x = NULL It is NULL (not known) on every row, and WHERE only keeps what is true, so 0 rows. Use IS NULL / IS NOT NULL. != drops the NULL rows too: add OR column IS NULL where needed.
Try it in this playground
Write your own WHERE Type your condition in the WHERE field. Every register row gets a mark: a tick, a cross, or a question mark for NULL.
Compare = NULL with IS NULL The first gives 0 rows, the second finds the empty ones.
Follow the run order Click WHERE then SELECT in the run order: the rows are filtered first, then their columns copied.
Cut with ORDER BY, then LIMIT Sort, then limit: the slips cut off are left as ghosts.