Reputation: 31
I am going to do a search. I have to put different condition for different person type. Could anybody tell me how to do this in Cypher? Cheers.
START ...
MATCH ...
WHERE
if person.type! ='Teacher'
...//add condition
else if person.type! ='Student'
...//add condition
else if person.type!='Assistant'
...//add condition
else
...//add condition
Return ...
Upvotes: 1
Views: 2100
Reputation: 2445
It's a little difficult to give you a complete answer without understanding what your // add condition
should be doing.
However, I suspect that what you are looking for is CASE
.
An example which may meet your requirements is something like this
MATCH (person:Person{name: "John"})
SET person.salary =
CASE person.type
WHEN 'Teacher' THEN 50000
WHEN 'Assistant' THEN 40000
WHEN 'Student' THEN 0
ELSE NULL
END
RETURN person
Upvotes: 2