LearnSQLSQL WHERE
FILTERING

SQL WHERE

Filter rows so only records that meet a condition are returned.

After this lessonUse comparisons and combine conditions with AND or OR.

How it works

WHERE removes rows that do not match your condition before the final result is returned. It is one of the most important SQL clauses for operational reporting.

Text values are normally quoted. Numbers are not. You can combine conditions with AND and OR, and use parentheses when the logic needs to be explicit.

REAL WORK

Filter an inventory export to items below a stock threshold or show only open production orders.

SYNTAX

The pattern

SELECT columns
FROM table
WHERE condition;

Example

SELECT *
FROM Orders
WHERE Status = 'Open';
TRY IT

Run the example

Edit the query and run it against the built-in demo tables. Nothing is sent to a server.

SQL playground

The learning runner supports SELECT, WHERE, LIKE, IN, BETWEEN, GROUP BY, HAVING, JOIN, aggregates, ORDER BY and LIMIT. Advanced lessons explain additional production SQL concepts even when the mini runner does not execute that syntax.

QUICK CHECK

Which operator means greater than or equal to?

Progress is stored only in this browser. No account required.