> For the complete documentation index, see [llms.txt](https://outerbase.gitbook.io/untitled/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://outerbase.gitbook.io/untitled/query-builder/select/where-clauses.md).

# Where clauses

A `WHERE` clause allows you to add conditionals into your SQL statement that fetch data only if certain criteria is met.

## Basic WHERE clause

When defining a where condition in a SQL statement it typically reads like:

```sql
SELECT * FROM table_name WHERE id = 100
```

Each condition typically follows the format of: `column` `operator` `value`. We offer a number of [Operators](/untitled/query-builder/operators.md) that help pre-compose the proper order and formatting to make it easier.

```typescript
const { data, error } = db
    .selectFrom([
        { 
            table: 'users', 
            columns: [
                'id', 
                'created_at', 
                'deleted_at'
            ]
        }
    ])
    .where(isNotNull('deleted_at'))
    .query()
```

## Multiple WHERE clauses

You can chain together multiple WHERE clauses to narrow down the rows that are returned.

```typescript
const { data, error } = db
    .selectFrom([
        { 
            table: 'users', 
            columns: [
                'id', 
                'created_at', 
                'deleted_at'
            ]
        }
    ])
    .where(isNotNull('deleted_at')) // User is not deleted
    .where(equalsNumber('id', 100)) // User ID is 100
    .query()
```
