[英]OPTIONAL MATCH and WHERE in Cypher
I'm struggling to write a cypher-query. 我正在努力写一个密码查询。
Graph 图形
The picutre bellow shows the complete graph. 下面的图片显示了完整的图表。 Some movies do not have a stuntman (the graph is fictional).
有些电影没有替身演员(图表是虚构的)。
Question 题
I wanna get ALL ACTORS (and THEIR MOVIES) who never played in a movie with a stuntman. 我想得到所有从未和电影艺术家一起演过电影的演员(以及他们的电影)。 In this case it would be "Johnny Depp"
在这种情况下,它将是“约翰尼德普”
This should work : 这应该工作:
MATCH (n:Actor)-->(m:Movie)
WHERE NOT (n)-->()<--(:Stuntman)
RETURN n AS actor, collect(m) AS movies
Cheers 干杯
PS: there is an other solution, but less performant I think : PS:还有另一个解决方案,但我觉得性能较差:
MATCH (n:Actor)-->(m:Movie)
WITH n AS actor, collect(m) AS movies
WHERE all(m IN movies WHERE not (m)<--(:Stuntman))
RETURN actor, movies
I think this will get you going 我想这会让你前进
// Find the actors and their movies
MATCH (a:Actor)--(m:Movie)
// where the actor was never in a movie with a stuntman
WHERE NOT (a)-[:ACTS_IN]-(:Movie)-[:ACTS_IN]-(:Stuntman)
RETURN a,m
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.