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

# WHERE

`WHERE` clause allows for filtering during the [MATCH](/docs/querying/match) phase. Compare this to the [FILTER](/docs/querying/filter) statment which allows results to be filtered after previous steps. The WHERE clause is part of the MATCH statement and is evaluated during the graph pattern-matching process. As such, it influences the PATH(s) returned by the [MATCH](/docs/querying/match) statement.

## Using WHERE clause in the Node and Edge Selection

Select all comments that posted after 2025-01-01

```mermaid theme={null}
%%{init: {'theme':'base', 'themeVariables': {'lineColor':'#F1FA8C','secondaryColor':'#F1FA8C','background':'#282A36'}}}%%
graph LR
    fatima[:Teacher <br/>name: Fatima 👩<br/>status: Active]
    uroosa[:Student <br/>name: Uroosa 👩<br/>status: Active]

    comment_1[:comment<br/>content: I love GQL<br/>comment_date:2025-01-01<br/>]

    fatima -->|:knowns<br/>since:2025| uroosa
    fatima -->|:likes| comment_1
    comment_1 -->|:author| uroosa

    classDef nodes fill:#BD93F9,stroke-width:0px
    class eva,fatima,angela,uroosa,eleni,scott nodes
	

    classDef subgraphStyle fill:#282A36, stroke-width:0px
    class row1,row2,row3 subgraphStyle
```

```gql theme={null}
USE graph social_network;

MATCH (x:comment WHERE x.comment_date > '2025-01-01')-[z:author]->(y)
RETURN y.name AS student_name, x.content AS comment_content
```

The first line selects the database to query, namely social\_network, and the second one specifies a path pattern to match in the graph. The last line defines what to return from the matched pattern.

The path pattern in the [MATCH](/docs/querying/match) pattern consists of three subpatterns, listed from left to right as they appear in the query. The first one matches any node, noted by `()`, where the `comment_date` is greater than '2025-01-01', storing identifiers in variable `x`. The second subpattern matches directional edges, captured by `-[]->`,that have an `author` label, and binding them to variable `z`. Finally, the third one matches any node, storing identifiers in y. Each of these subpatterns yields a set of paths, where a path is defined as an alternating sequence of nodes and edges, starting and ending with a node. In particular, edge patterns yield the edge’s identifier and include the connected nodes that form the path.
