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

# WHERE

> Optional clause used to filter results based on predicates.

The `WHERE` clause is optional and is used to filter results based on predicates (conditions).

## Supported Comparison Operators

| Operator      | Description                  |
| ------------- | ---------------------------- |
| `=`           | Equal to                     |
| `<>`          | Not equal to                 |
| `<`           | Less than                    |
| `<=`          | Less than or equal to        |
| `>`           | Greater than                 |
| `>=`          | Greater than or equal to     |
| `CONTAINS`    | String contains substring    |
| `ENDS WITH`   | String ends with substring   |
| `IN`          | Value is in list             |
| `STARTS WITH` | String starts with substring |

## Combining Predicates

Predicates can be combined using the logical operators `AND`, `OR`, and `NOT`.

Use parentheses to control precedence when combining multiple predicates.

### Examples:

```sql theme={null}
WHERE (actor.name = "john doe" OR movie.rating > 8.8) AND movie.votes <= 250
```

```sql theme={null}
WHERE actor.age >= director.age AND actor.age > 32
```

## Inline Property Filters

You can specify equality predicates directly within node patterns using curly braces:

```sql theme={null}
(:President {name:"Jed Bartlett"})-[:WON]->(:State)
```

This requires that the president node's `name` property equals "Jed Bartlett".

Inline predicates are functionally equivalent to predicates specified in the WHERE clause.

## Pattern Predicates

You can also filter based on graph patterns. These two queries are equivalent and both return presidents and the states they won:

```sh theme={null}
MATCH (p:President), (s:State) WHERE (p)-[:WON]->(s) RETURN p, s
```

```sh theme={null}
MATCH (p:President)-[:WON]->(s:State) RETURN p, s
```

Pattern predicates can be negated and combined with logical operators. This query returns presidents who did not win in states where they were governors:

```sh theme={null}
MATCH (p:President), (s:State) WHERE NOT (p)-[:WON]->(s) AND (p)-[:GOVERNOR]->(s) RETURN p, s
```

## Label Filtering

Nodes can be filtered by label in the WHERE clause:

```sh theme={null}
MATCH (n)-[:R]->() WHERE n:L1 OR n:L2 RETURN n 
```

**Best Practice:** When possible, specify labels directly in the node pattern of the MATCH clause for better performance.

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="What comparison operators does WHERE support?">
    FalkorDB supports `=`, `<>`, `<`, `<=`, `>`, `>=`, plus string operators `CONTAINS`, `STARTS WITH`, `ENDS WITH`, and the list operator `IN`.
  </Accordion>

  <Accordion title="Can I combine multiple conditions in WHERE?">
    Yes. Use `AND`, `OR`, and `NOT` logical operators to combine predicates. Parentheses control evaluation precedence.
  </Accordion>

  <Accordion title="What are inline property filters?">
    Inline filters use curly braces within node patterns, e.g. `(n:Person {name: 'Alice'})`. They are functionally equivalent to a WHERE clause equality check but offer more concise syntax.
  </Accordion>

  <Accordion title="Do WHERE predicates benefit from indexes?">
    Yes. When a WHERE clause filters on a property that has a **range index**, FalkorDB automatically uses an index scan instead of a full label scan. Use `GRAPH.EXPLAIN` to verify index usage.
  </Accordion>

  <Accordion title="Can I filter by graph patterns in WHERE?">
    Yes. Pattern predicates like `WHERE (a)-[:KNOWS]->(b)` or negated patterns `WHERE NOT (a)-[:KNOWS]->(b)` can be used directly in the WHERE clause.
  </Accordion>
</AccordionGroup>
