Neo4j Cypher查询包含起始节点

4
我想列出我参演的所有电影以及每部电影中演员的总数,但是下面的查询只返回除我以外的演员总数,并且不会返回没有其他演员的电影。
start me=node({0}) 
match me-[:ACTS_IN]->movie<-[:ACTS_IN]-otherActors 
return movie, count(*) as actorSum
1个回答

5
你需要用WITH来分隔。你查询的问题在于你在match的第一部分中声明了me节点,因此me永远不可能出现在otherActors中。
start me=node({0}) 
match me-[:ACTS_IN]->movie
with movie   
match movie<-[:ACTS_IN]-actors 
return movie, count(*) as actorSum

那正是我在寻找的。不过,接下来的问题是,这会对性能产生影响吗? - Roee Gavirel

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接