Skip to content
/Chapter 3 · Select, Filter, and Sort
Lesson 3.3·garden_shop
Lesson 3.3

Combining Conditions with AND, OR & 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 ShopTable · products9 columns · 24 rows
Table · products

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

9 columns · 24 rows
product_id intproduct_name textcategory_id intsupplier_id intprice decimalcost decimalquantity_on_hand intreorder_level intdiscontinued 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.

SQL Workbench
query.sqlgarden_shop · SQL engine loading
⌘↵ to run
·
Expected answer
  • Columns: product_name, price, quantity_on_hand.
  • Rows: 11 products.
  • No discontinued products should appear.