Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有多个“with”子句的复杂查询。我需要其中一场比赛完全是可选的。例如:
m-[:LOVES]->f-[:FATHERED]->d-[:SISTER_OF]-s collect(d) as daughters
只有当所有其他关系都为真时,我才需要返回 d,但有可能女儿是空的。现在,没有任何部分是可选的,我的整个查询返回空。
尝试:
m-[:LOVES]->f-[:FATHERED]->d-[?:SISTER_OF]-s collect(d) as daughters
s如果不匹配,它将返回 null 。
s
一般来说,我会将两场比赛分开:
MATCH m-[:LOVES]->f-[:FATHERED]->d WITH DISTINCT d MATCH d-[?:SISTER_OF]-s RETURN collect(d) as daughters