Chapter 5 — Further Reading

The official references for everything in this chapter, plus drills. The best "further reading" here is more queries — see the "Do" section.

Official reference (everyone)

  • PostgreSQL Docs: "Queries" → "Table Expressions," "The WHERE Clause," "Sorting Rows (ORDER BY)," "LIMIT and OFFSET." The authoritative spec for everything in this chapter, with edge cases. https://www.postgresql.org/docs/current/queries.html
  • PostgreSQL Docs: "Pattern Matching." LIKE, ILIKE, SIMILAR TO, and POSIX regex (~, ~*). When LIKE isn't enough but full-text search (Ch. 16) is overkill.
  • PostgreSQL Docs: "Comparison Functions and Operators." The exact behavior of =, <>, BETWEEN, IN, IS NULL, and three-valued logic.

Build fluency (💻 Developer · 📊 Analyst)

  • Alan Beaulieu, Learning SQL (O'Reilly) — early chapters. A gentle, well-paced companion to Part II's basics, with plenty of examples.
  • Anthony DeBarros, Practical SQL (No Starch). Hands-on and PostgreSQL-based; great if you like learning by doing on real datasets.
  • Interactive practice sites (e.g., pgexercises.com, SQLZoo, Mode's SQL tutorial). Short, gamified query drills. Twenty minutes a day for a week and basic SQL becomes reflex.

On query correctness (🏗️ DBA · 💻 Developer)

  • Articles on SQL operator precedence and "the AND/OR trap." Reinforce Case Study 1: why mixed boolean logic without parentheses is a classic bug.
  • Markus Winand, SQL Performance Explained / use-the-index-luke.com — the "WHERE clause" sections. A preview of why the way you filter affects whether an index can help (Chapter 23). Read the intro now; save the rest.

Reference cards (everyone)

  • Appendix C — SQL Quick Reference (this book): the SELECT skeleton and operators on one page.
  • Appendix J — SQL Dialect Differences (this book): LIMIT vs. FETCH FIRST vs. TOP, ILIKE vs. LOWER(...), concatenation operators.

Do, don't just read

  • Re-answer your Chapter 1 questions in SQL. Anything expressible with one table — do it now. The rest will come with joins.
  • Deliberately trigger each "common mistake": write phone = NULL and watch it return nothing; write a mixed AND/OR without parentheses and predict the wrong result; run LIMIT 5 with and without ORDER BY a few times and watch the rows shift. Making the bugs happen on purpose is the fastest way to never make them by accident.
  • Type, don't copy. Muscle memory for WHERE, ORDER BY, LIMIT only forms through your own fingers.

Next: Chapter 6 — JOINs, the most important SQL skill — connecting tables.