I have a database formatted like this:
(a:Concept)-[r:BROADER_TERM]->(b:Concept)-[s:BROADER_TERM]->(c:Concept)-[t:RELATED_TERM]->(d:Concept)
I’d like to write a query that returns Concept
nodes that only have incoming BROADER_TERM
edges and excludes any node that has both incoming and outgoing BROADER_TERM
edges (ie I want to return the ‘broadest term’). In the example above, it would be a query that only returns node c
.
I tried something like this:
MATCH (a:Concept)-[r:BROADER_TERM]->(b)
WHERE NOT (b)-[r]->(c:Concept)
RETURN b
But I can’t introduce a new variable in the WHERE NOT
clause.
Can someone show me the correct syntax for this type of query?