Skip to content

WHERE Clause

In one line

The WHERE clause filters rows in a query — only rows where the condition is true are included in the result.

In simple words

The WHERE clause is how you filter rows in a SQL query. It takes a condition (an expression that evaluates to true, false, or NULL) and keeps only the rows where the condition is true.

You can combine conditions with AND, OR, and NOT. Common operators include =, !=, <, >, LIKE (pattern matching), IN (membership in a list), BETWEEN (range), and IS NULL (null check).

WHERE is used in SELECT, UPDATE, and DELETE — it determines which rows to read, modify, or remove. It is applied before grouping, so you cannot use aggregate functions in WHERE (use HAVING for that).

Example

sql
-- Find users who are active and over 18
SELECT * FROM users
WHERE active = TRUE AND age > 18;

-- Pattern matching with LIKE
SELECT * FROM users WHERE email LIKE '%@example.com';

The first query filters by two conditions with AND. The second uses LIKE for pattern matching.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary