Skip to content
/ Chapter 3 · Filtering in Depth
Lesson 3.2 · garden_shop
Lesson 3.2

Combining Conditions with AND, OR, and Parentheses

When a filter has multiple conditions, parentheses make your intent explicit.

AND and OR let one WHERE clause check more than one thing. Use AND when every condition must be true. Use OR when any condition can be true.

Parentheses matter when you mix them. They show which conditions belong together, the same way they do in arithmetic.

Pattern
select column_one, column_two
from table_name
where (condition_a or condition_b)
  and condition_c
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 each product's product name, price, and quantity on hand when the product costs more than $20 or has fewer than 10 units on hand. Exclude discontinued products.

·

Run your query to inspect the result.

Expected answer
  • Columns: product_name, price, quantity_on_hand.
  • Rows: 11 products.
  • No discontinued products should appear.