我正在尝试进行查询,查询成功或失败时将返回一个布尔值。因此,成功时将为true,失败时将为false:
这是我的要求,在RETURN
之后,我尝试了neo4j
:
MATCH (n:User),(d:Song)
WHERE n.username = "syord"
AND d.title = "Hello"
CREATE (n)-[r:PURCHASED]->(d)
SET n.totalStars = 999999
RETURN CASE
WHEN n IS NULL
THEN false
ELSE true
END
AS n
成功时返回true,但失败时我什么也没得到:(no changes, no records)
。
答案 0 :(得分:2)
MATCH (n:YourLabel) RETURN count(n)>0 AS result;
╒════════╕
│"result"│
╞════════╡
│false │
└────────┘
MATCH (n:User),(d:Song)
WHERE n.username = "syord"
AND d.title = "Hello"
CREATE (n)-[r:PURCHASED]->(d)
SET n.totalStars = 999999
RETURN count(n)>0
AS n