SQL reference

SQL WHERE: filter the rows you want

In Excel, you'd reach for
fxThe filter dropdown (Data > Filter)

WHERE keeps only the rows that pass your test, like ticking boxes in Excel's filter dropdown, except you describe what you want instead of clicking.

  • =, <> (not equal), >, <= for comparisons
  • BETWEEN '2026-03-01' AND '2026-03-31' for ranges (both ends included)
  • IN ('India', 'Canada') for "any of these"
  • LIKE '%@gmail.com' for text patterns (% = anything)
  • IS NULL / IS NOT NULL for blanks. = NULL never matches anything.
SQL order of execution: FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY, LIMIT, with the Excel equivalent of each step
The order SQL runs a query in, with the Excel step each one is like. Download · Save to Pinterest

Syntax

SELECT columns
FROM table
WHERE condition AND other_condition;
Try itEdit the query, then Run
idopened_atpriorityagent
342026-03-07 12:00urgentEmma
1042026-04-17 03:00urgentDiego
3202026-06-11 14:00urgentBruno
4652026-06-27 01:00urgentEmma

4 rows

Mixing AND with OR? Use brackets so it does what you mean: WHERE region = 'Europe' AND (quantity > 3 OR product_id = 2).

Your turn

Find orders from the Europe or Latin America regions with a quantity above 4. Show id, region and quantity.

This page on one card

SQL WHERE: filter the rows you want: the Excel way (The filter dropdown (Data > Filter)) and the SQL query, side by side
SQL WHERE: filter the rows you want, on one card: the Excel way and the SQL. Download · Save to Pinterest
The practice data (7 tables)

See every column and sample rows