# WHERE Clause

> The part of a SQL command that keeps only the rows that pass a test.

**Field:** Software Development  
**Category:** Databases  
**Also known as:** WHERE, SQL WHERE, SQL Filter

## Think of it like

It is like a sieve. Only the rows that pass the test fall through.

## Definition

A WHERE clause is the part of a SQL command that picks which rows it works on. It holds a test, like city = 'Paris' or price > 10. Only the rows that pass the test are kept. You can join tests with AND and OR. It works in SELECT to filter what you read, and in UPDATE and DELETE to aim the change.

## Example

Jack only wants this week's orders. He adds WHERE created_at >= '2026-11-09' and gets just those rows.

## Example code

```sql
SELECT name
FROM customers
WHERE city = 'Paris' AND active = true;
```

Only customers who live in Paris and are active come back.

## Why it matters

It decides which rows a command touches. In a DELETE, a missing or wrong WHERE can wipe the wrong data.

## Common mistake

Testing for an empty value with = NULL. It never matches. Write IS NULL instead.

## Three principles

- **A test per row.** Rows that pass are kept.
- **AND and OR.** Join tests to be more exact.
- **Aims changes too.** UPDATE and DELETE use it to pick rows.

## Related terms

- [SELECT Statement](https://learn.benibix.com/term/development/select-statement)
- [Structured Query Language (SQL)](https://learn.benibix.com/term/development/sql)
- [GROUP BY Clause](https://learn.benibix.com/term/development/group-by)
- [Database Index](https://learn.benibix.com/term/development/database-index)
- [Create, Read, Update, Delete (CRUD)](https://learn.benibix.com/term/development/crud)

![A table of six orders, each with a city and an amount. An arrow marked WHERE amount > 10 keeps four of the rows and drops two. An arrow marked GROUP BY city puts the four rows into two piles, London and Paris. An arrow marked SUM(amount) turns each pile into one row: London 45 and Paris 30. The last box is the result the SELECT gives back.](https://learn.benibix.com/diagrams/dev-sql-query.svg)

---

Source: https://learn.benibix.com/term/development/where-clause
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-16
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
