CSE Roadmap

Core tier · about 3 hours · 5 parts

Part 2 of 5 · 1 min read

Filtering with WHERE

Comparison and logical operators, and how conditions combine.

Think of sorting a box of photographs by hand. First keep only the ones from one specific year. Then, within those, keep only the ones that also show more than one person.

In plain words: WHERE narrows a result to rows matching a condition. Conditions use comparison operators like =, <, >, <=, >= and <>. Several conditions combine with AND, requiring all of them, or OR, requiring at least one. Parentheses control how mixed AND and OR conditions group together.

A worked example. Finding every order placed in 2026 for customer 107.

The key lines.

SELECT order_id, placed_on
FROM orders
WHERE customer_id = 107 AND placed_on >= '2026-01-01';

Comparison operator, logical operator

A comparison operator tests a relationship between two values, such as = or >. A logical operator, AND or OR, combines two or more conditions into one.

Example: customer_id = 107 AND placed_on >= '2026-01-01' combines two comparisons with one logical operator.