Skip to content
/ Chapter 1 · Welcome to the Shed
Lesson 1.5 · garden_shop
Lesson 1.5

SQL WHERE: Filtering Rows

Most of the time you don't want every row, just the ones that matter.

The WHERE clause keeps only the rows that meet a condition, and throws the rest away before they ever reach your results.

It goes right after FROM, and you can compare with =, <, >, and more. Conditions can be combined with AND and OR, which Chapter 3 covers.

Pattern
select column_one, column_two
from table_name
where number_column < 10

Check filters in small steps

When a WHERE clause has more than one condition, test one condition first, then add the next one. If the result suddenly drops to zero rows, the last condition is the place to inspect.

Text comparisons need quotes, numbers usually don't, and dates should use a clear date format. If a row is missing a value, ordinary comparisons may skip it; later lessons cover SQL NULL handling.

Schema · Garden Shop Table · products 9 columns · 24 rows
Table · products

One row per product, with price, cost, and inventory levels.

9 columns · 24 rows
product_id int product_name text category_id int supplier_id int price decimal cost decimal quantity_on_hand int reorder_level int discontinued bool
Your task

Show the product name and price of every product that costs less than $10.

·

Run your query to inspect the result.

Expected answer
  • Columns: product_name, price.
  • Rows: 9 products priced under $10, in any order.
  • The cheapest is Tomato Seeds 'Roma' at 2.75; Garden Trowel at 9.5 just makes it.