While using the WHERE
clause in cypher queries how do one join multiple conditions?. Is it valid to use AND
as in WHERE condition1 AND condition2
or what’s the valid way to do something of such?.
9 Answers
Yes, it's precisely that way. You can use your condition inside the vertex/edge too, like this:
SELECT * FROM cypher('graph_name', $$
MATCH (n:Vertex {property: 'value'})-[e {property: 'value'}]->(v)
RETURN (v)
$$) as (v agtype);
This is the equivalent of:
SELECT * FROM cypher('graph_name', $$
MATCH (n:Vertex)-[e]->(v)
WHERE n.property = 'value' AND e.property = 'value'
RETURN (v)
$$) as (v agtype);

- 763
- 1
- 12
Yes, it is possible to use AND
to join conditions. Other boolean operators are also available such as:
OR
: True when either or both conditions are trueXOR
: True when either but not both conditions are trueNOT
: True when the condition is false
This Neo4j documentation about the WHERE
clause contains a whole lot of useful information that should be helpful.

- 397
- 1
- 13
You can use AND, OR, NOT inside your WHERE section. Such as:
SELECT t.name, t.age
FROM schema_name.sql_person as t
WHERE EXISTS (
SELECT *
FROM cypher('graph_name', $$
MATCH (v:Person)
RETURN v.name, v.age
$$) as (name agtype, age agtype)
WHERE name = t.name AND age = t.age
);
You can follow official docs.

- 1
- 2
Yes it is valid to use AND and OR statements in WHERE clause to join the condition. The valid syntax is as follows:
MATCH (node)
WHERE condition1 AND condition2
RETURN node
If you want to know if either of the condition is true for nodes. Use this:
MATCH (node)
WHERE condition1 OR condition2
RETURN node
You can also combine the statements:
MATCH (node)
WHERE (condition1 AND condition2) OR condition3
RETURN node

- 375
- 8
Age is an extension that provides you with a query joining method.
You can join the statements using AND operator, where every statement will be joined using an AND operator.
For example you have a student and you want to retrieve a student with a certain age and major. You can write query for above statement like as under:
MATCH (n:Student)
WHERE n.age > 25 AND n.major = 'Computer Science'
RETURN n
This is how joining different statements in apache age work.

- 121
- 5
Yes, it's valid. You can also use other operators such as:
IS NULL: Checks if a property or expression is null.
IS NOT NULL: Checks if a property or expression is not null.
IN: Checks if a property or expression matches any value in a given list.
NOT IN: Checks if a property or expression does not match any value in a given list.
STARTS WITH: Checks if a string property or expression starts with a specified substring.
Please read: WHERE Cypher

- 115
- 5
You can create compound expressions by using AND and OR in WHERE clause. AND had priority over OR and () have priority over both.
MATCH (n:Node)
WHERE (n.property1 = 'value1' OR n.property2 = 'value2') AND n.property3 = 'value3'
RETURN n

- 433
- 9
Yes, it is valid to use AND
and WHERE
clause of a Cypher query to join multiple conditions Like:
MATCH (n: Person ) WHERE n.age < 30 AND n.name = 'Peter' RETURN n.name, n.age
This will return the name and age values for Peter because he is less than 30 years age and his name is Peter.

- 10
Yes, it is possible to use AND in WHERE clause, along with AND you can also use other boolean variables.

- 39
- 3