Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Match with OR condition

Tags:

neo4j

cypher

been playing around with cypher for a while now and having a bit of difficulty understanding something.

assuming i have person nodes some of which might have a belongs_to relationship what would be the best way to find a node that either

  • does not have a blongs_to relationship but does have an email address of "[email protected]"
  • OR
  • does have a belongs_to relationship with a Id Property of "100" ( the property is of the relationship)

i have managed to create some queries that return the expected data, but i don't know if those are ones that are "correct" in the long run of my cypher understanding

any help would be appreciated. ( specifically with regards to And | Or , order and efficiency )

like image 311
cechode Avatar asked Oct 20 '14 20:10

cechode


People also ask

How do you write an IF THEN formula in Excel?

Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it's false. For example: =IF(A2>B2,"Over Budget","OK") =IF(A2=B2,B4-A4,"")

Can you use VLOOKUP with two conditions?

Can you combine the IF function and the VLOOKUP function? Yes, you can, in fact, it is the easiest way to VLOOKUP using two or more conditions. To enter an array formula press and hold CTRL + SHIFT simultaneously, then press Enter once. Release all keys.


1 Answers

Something like this?

You can use path patterns as predicates, see: http://neo4j.com/docs/2.1.5/query-where.html#query-where-patterns

MATCH (n:Person {email:"[email protected]"})
WHERE NOT (n)-[:BELONGS_TO]->() OR (n)-[:BELONGS_TO {id:100})->()
RETURN n
like image 183
Michael Hunger Avatar answered Oct 13 '22 05:10

Michael Hunger