The WHERE clause
WHERE filters: it only returns the rows that meet a condition.
SELECT name, price FROM products WHERE price > 100;
Common comparison operators:
| Operator | Meaning |
|---|---|
= |
equal |
<> |
not equal |
> < >= <= |
greater / less (than or equal) |
For text, comparisons go between single quotes:
SELECT * FROM products WHERE category = 'peripherals';
You can combine conditions with AND and OR:
SELECT * FROM products WHERE price > 20 AND category = 'peripherals';