2
votes

I'm trying to run a query in which one of the nodes in the path can be from two labels. I want to use a "CASE WHEN THEN" pattern that will be based on the node's label,such as:

match (a)-[r1:SOME_RELATION]-(b:BBB)-[r2:SOME_OTHER_RELATION]->(c:CCC) return a.name, CASE labels(a) WHEN 'ANIMAL' THEN 1 ELSE 0 END as a_type order by a.name

how can I comapre the label's value?

thanks

1

1 Answers

5
votes

Ok, I found the answer:)

match (a)-[r1:SOME_RELATION]-(b:BBB)-[r2:SOME_OTHER_RELATION]->(c:CCC) return a.name, CASE a:ANIMAL WHEN true THEN 1 ELSE 0 END as a_type order by a.name

Hope it will help someone:)