SELECT chooses columns. To choose rows, add a WHERE clause after FROM. It holds a condition: a test that each row either passes or fails. Only the rows that pass come back.
SELECT name, price
FROM products
WHERE category = 'Garden';
Returns
name | price
------------+------
Duck feeder | 24
Bird bath | 45.5
Pond net | 12.5
(3 rows)
Text values go inside single quotes: 'Garden'. Without them the database would think Garden was the name of a column. Numbers don't need quotes:
SELECT name, price
FROM products
WHERE price > 40;
<= less than or equal to, >= more than or equal to
Text has to match exactly. 'garden' with a small g finds nothing here, because when you compare text with =, capital letters count.
Dates in this database are stored as text in the form year-month-day, like '2024-09-15'. Written that way, earlier dates come first in alphabetical order, so < and > work on them: < means before and > means after. The orders placed in October or later:
SELECT id, ordered_on
FROM orders
WHERE ordered_on >= '2024-10-01';