cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to maintain the OR relationship between multiple WHERE

How to maintain the OR relationship between multiple WHERE;
The sentence is
match(n:Column) where (n.chineseName Contains 'path' or n.name Contains 'path' or n.comment Contains 'path') optional match(n) <- [r:Contains]- (m:Document) where m.name Contains 'path' RETURN n, r, m.
I want to maintain the OR relationship between the first WHERE and the second WHERE.
May you help me? Thank you!

1 REPLY 1

I am not fully sure what you are asking, but I will assume I do.

The result of the first match are all Column nodes that meet the condition in the first 'where' clause. Each resulting Column node bound to the variable 'n' is passed to the next phase of the query, the 'optional match'. In this case, you are matching each 'Column' node already determined to 'Document' nodes. Since the variable 'n' has already been determined with the first where clause, they don't need to be repeated in the second where clause. The second where clause only needs to contain conditions for the new 'r' and 'm' variables.

Does this address your question?