Junior Track Roadmap

SQL: where & operators

This course covers how SQL filters rows with the WHERE clause in PostgreSQL, alongside the ActiveRecord code that generates each query. It starts with comparison operators and moves through AND, OR and NOT, operator precedence, LIKE and ILIKE pattern matching, IN and BETWEEN, and NULL handling with three-valued logic. Later lessons deal with timestamps and time zones in Rails, then with B-tree indexes, sargability, EXPLAIN ANALYZE, and expression and partial indexes. Parameterized queries and SQL injection come up throughout.

What you'll learn

  • ✓Filtering rows with WHERE and the six comparison operators
  • ✓Combining conditions with AND, OR and NOT, and using parentheses for precedence
  • ✓Pattern matching with LIKE, ILIKE and safe parameterized search
  • ✓Filtering lists and ranges with IN, BETWEEN and Ruby ranges
  • ✓Testing for NULL with IS NULL, IS NOT NULL and COALESCE
  • ✓Writing sargable conditions and reading plans with EXPLAIN ANALYZE
Free preview · Lesson 1 7 min read

The WHERE clause

Imagine a nightclub with a thousand people inside. You don't want to talk to everyone: you want to find your friend who's wearing a red jacket. Instead of scanning every face, you tell the bouncer: "Only let through people in red jackets." The bouncer filters the crowd, and only matching people…

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...