> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.omni.co/feedback

```json
{
  "path": "/modeling/relationships/parameters/where-sql",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# where_sql

> Adds a WHERE clause to the generated SQL when a join is established.

This parameter applies a filter condition to all rows in the query after the join has been performed. The clause does **not** pre-filter then join; it joins first and then uses the `WHERE` statement to filter the results.

## Syntax

```yaml theme={null}
where_sql: <sql_filter_condition>
```

## Properties

<ParamField path="where_sql" type="string">
  A SQL condition that filters rows after the join is performed. Use `${view_name.field_name}` syntax to reference fields.
</ParamField>

## Examples

```yaml title="Only include rows with order counts greater than 20" highlight={6} theme={null}
- join_from_view: users
  join_to_view: orders
  join_type: always_left
  on_sql: ${users.id} = ${orders.id}
  relationship_type: many_to_one
  where_sql: ${orders.count} < 20
```
