Parameters
Parameters in cypher queries are an advanced function that allows you to control certain behaviors. By setting specific variable values within the query, you can customize how the query runs to fit particular needs or configurations.
Using parameters can increase the flexibility and efficiency of your queries. You can think of parameters as reusable variables that you declare once and then use in multiple places.
MATCH (n:Person)
WHERE n.location = 'New York'
RETURN n
MATCH (n:Person)
WHERE n.location = 'New York'
RETURN n
In this example, n.location
is the "location" parameter of node n
.
If you want to apply query parameters, do it as follows:
- First, add the parameter
- Then create a query using this parameter
MATCH (n:Person)
WHERE n.location = $location
RETURN n
MATCH (n:Person)
WHERE n.location = $location
RETURN n
In this case, we have defined a query parameter, 'location', as 'New York'. This is then used in our query via the $location
variable. Parameters such as these can be reused in multiple places within the same query, increasing the efficiency and readability of your code.
TIP
The combination of the parameters and Save query functionality is very effective because you can create a query, add parameters, and save everything to use it later on.