关于cypher检索
发布于 7 年前 作者 goldenroc 2679 次浏览 来自 问答

match (n)-[r:关系名称|关系名称2]-() where id(n)=0 return n,r 使用上面的查询,如果指定关系名称,结果无法返回未创建关联的节点,如果需要返回无关联节点该如何写

6 回复

match (n) , (m) where id(n)=0 and NOT (n)-[r:关系名称|关系名称2]- (m) return n,r,m

可以返回 没有创建指定关联 的节点。 是你想要的结果吗?

你是想要 如果建立了关联 则将关联一起返回,如果没建立关联则只返回 节点? 这样就可以了加上 OPTIONAL MATCH match (n)-[r:关系名称|关系名称2]-() where id(n)=0 optional match (n) where id(n)=0 return n,r

这样就可以了加上 OPTIONAL MATCH match (n)-[r:关系名称|关系名称2]-() where id(n)=0 optional match (n) where id(n)=0 return n,r

回到顶部