Home › Learn › SQL › Reading rows

WHERE

Lesson 3 of 26. Keep only the rows that match a condition.

WHERE filters rows: SELECT name, price FROM products WHERE price < 30; keeps the rows whose price is below 30. Comparisons are =, <> (not equal; != also works), <, >, <=, >=. Text values go in single quotes, 'hardware', and text comparisons with = are case-sensitive in SQLite.

The WHERE clause comes after FROM. It looks at each row on its own; conditions that compare rows to each other need the tools from later modules.

SELECT name, salary FROM employees WHERE dept = 'Sales';

Your task

Show the name and price of the products that cost less than 30.

Hint 1

Add WHERE price < 30 before the semicolon.

Show the solution
SELECT name, price FROM products WHERE price < 30;

    Runs SQLite compiled to WebAssembly in this tab; the database is rebuilt before every run.