Fayaz
Fayaz

Reputation: 334

find the first node in path not having relationship

I have relationships and nodes like this

(x:Execution)-[:with]->(first:Param)->[:with]-(second:Param)-...[:with]->(last:Param)

Here (Param) can be any number of times and (Execution) is optional and may be missing. I need to find all such (first:Param) where (Execution) is missing.

Can anyone help me write Neo4j Cypher query for this?

Upvotes: 0

Views: 235

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30397

If this can be accurately described as a :Param node with no incoming :with relationship, you can use this to find your nodes:

MATCH (first:Param)
WHERE NOT ()-[:with]->(first)
RETURN first

Upvotes: 1

Related Questions