问题描述
我尝试了大量密码查询,大部分来自 this question,但都没有奏效。
例如:
postgres=# match (a)<-[r]-() where r is null return *;
a | r
---+---
(0 rows)
我试过的最后一个是这样的:
match (n) where not (n)<-[]-() return *
获得语法错误:
postgres=# match (n) where not (n)<-[]-() return *;
ERROR: Syntax error at or near ")"
LINE 1: match (n) where not (n)<-[]-() return *;
我终于启动了 Neo4j,发现上面提到的密码查询在那里工作。
AgensGraph (2.1.3) Cypher 中的等价物是什么?
注意
- 将所有具有传出关系的节点标记为 children
match (a)<-[]-(b) SET b.child=true;
- 查找所有非子节点
match(a) where a.child is null return a;
- 删除子标记
match(a) where a.child is not null remove a.child;
解决方法
您的查询 match (n) where not (n)<-[]-() return *;
很接近,但是您需要再添加 2 个元素才能使查询工作。
- 您的模式 (n)
- 你需要在你的模式前加上 EXISTS
所以我运行了这个查询:MATCH (a) WHERE NOT EXISTS ((a)<-[]-()) RETURN *;
并且它起作用了。