0PricingLogin
SQL Academy · Lesson

WHERE Filters: Comparison and Logic Operators

Filter rows with =, <>, , AND, OR, NOT and understand operator precedence and parentheses.

The Role of WHERE

WHERE filters rows before grouping or aggregation. Only rows where the predicate is TRUE are returned.

Comparison Operators

Standard comparisons work on all comparable types:

SELECT * FROM products WHERE price > 100;
SELECT * FROM products WHERE price >= 100;
SELECT * FROM products WHERE price < 50;
SELECT * FROM products WHERE price <= 50;
SELECT * FROM products WHERE category = 'books';
SELECT * FROM products WHERE category <> 'books';   -- != also works

All lessons in this course

  1. Selecting Columns and Expressions
  2. WHERE Filters: Comparison and Logic Operators
  3. ORDER BY Single and Multiple Columns
  4. LIMIT, OFFSET and Pagination Basics
← Back to SQL Academy