Finding nodes that do not have specific relationship (Cypher/neo4j)

前端 未结 2 1696
梦如初夏
梦如初夏 2021-01-07 19:49

I have a neo4j db with the following:

a:Foo
b:Bar

about 10% of db have (a)-[:has]->(b)

I need to get only the nodes

相关标签:
2条回答
  • 2021-01-07 20:38

    This also works if you're looking for all singletons/orphans:

    MATCH (a:Foo) WHERE not ((a)--()) RETURN a;
    
    0 讨论(0)
  • 2021-01-07 20:41

    That would be

    MATCH (a:Foo) WHERE not ((a)-[:has]->(:Bar)) RETURN a;
    
    0 讨论(0)
提交回复
热议问题