SELECT, Filtering and Sorting - Database Cheat Sheet
How SQLite reads a query, clause by clause, with the real row count after each one. Then WHERE and every comparison, LIKE and its wildcards, IN, BETWEEN, IS NULL, AND and OR, ORDER BY, DISTINCT and a computed age.
On the sheet:
- How SQLite reads a query: run order against written order, with row counts
- SELECT: choose the columns, and join text with || and AS
- Quotes follow the type: text, numbers and dates
- WHERE: the comparison operators and the boundary
- = or LIKE: capital letters, and the % and _ wildcards
- IN, NOT IN and BETWEEN: lists and inclusive ranges
- NULL: why = NULL finds nothing, and IS NULL
- AND, OR and NOT: the rows each one keeps, counted
- ORDER BY, DISTINCT and a computed age: and the alias WHERE should not use
Two A4 pages, printed front and back, sized to print once and keep beside you while you work. Written in short sentences and plain English, for readers whose first language is not English and clearer for everyone else because of it.
It pairs with the Asking Questions: SELECT, Filtering & Sorting Like a Pro and Querying & Filtering Data books, so you can learn each idea in full and then revise it here in two pages.
Every query on this sheet was run against a live database before the page was printed, so the result you read is the result you get. Instant PDF download. By M.R. Sterling.