[英]PHP Neo4j NOT relationship query is not working
I am trying to execute the NOT relation
query but the condition just does not apply. 我试图执行
NOT relation
查询,但条件不适用。 What am I doing wrong here? 我在这做错了什么?
The query I tried: 我试过的查询:
MATCH (blog:Blog), (user:User{id:3})-[:FOLLOWS]->(otherUser:User)
WHERE NOT ((otherUser)-[:OWNS]->(blog))
RETURN blog
Query should return - all blogs that my friends do not own. 查询应该返回 - 我的朋友不拥有的所有博客。 My id is 3. So all the blogs owned by other users should be returned.
我的身份证是3.所以应该返回其他用户拥有的所有博客。
You span up a cross product between all blogs and all friends of the user. 您跨越了所有博客和用户的所有朋友之间的交叉产品。
But the condition is only checked for each pair. 但只检查每对的条件。
You probably want this: 你可能想要这个:
MATCH (user:User{id:3})
MATCH (blog:Blog)
WHERE NOT ((user)-[:FOLLOWS]->()-[:OWNS]->(blog))
RETURN blog
or this 或这个
MATCH (user:User{id:3})-[:FOLLOWS]->(otherUser:User)
WITH collect(otherUser) as friends
MATCH (otherUser)-[:OWNS]->(blog:Blog)
WHERE NOT otherUser IN friends
RETURN blog
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.