Memra

Filtering rows with WHERE

Keep only the rows that match a condition.

Keep the rows you want

WHERE filters rows by a condition — only rows for which it's true come back:

SELECT title, price
FROM books
WHERE genre = 'fiction';

Text literals go in single quotes ('fiction'), never double. Numbers are bare. The usual comparisons all work: =, <> (not equal), <, <=, >, >=.

SELECT title FROM books WHERE price < 12;
NORMAL ~/memra/learn/postgresql/where-filtering-rows utf-8 LF