Module 02 · lesson 2
Comparison operators
Marketing is preparing a "premium products over $100" selection. Equality won't do here — you need a comparison by magnitude.
Comparing by magnitude
Besides =, WHERE offers comparison operators:
>greater,<less;>=greater or equal,<=less or equal;<>(or!=) not equal.
WHERE category <> 'Electronics' --all categories except electronics
WHERE created_at > '2024-02-01' --created after February 1, 2024
For example, let's find products with fewer than 10 left in stock:
SELECT name, stock
FROM products
WHERE stock < 10;
You can compare not only numbers but also text (alphabetically) and dates (earlier/later). Numbers in a condition are written without quotes (because in quotes it's no longer a number, but text).
Your turn
Marketing needs products more expensive than $100. Output their name and price.
Summary
>/<— greater / less>=/<=— greater or equal / less or equal<>(or!=) — not equal.