方法一:case when
MATCH (n:Test{id:"Q1"}),(n1:Test{id:"Q2"})
RETURN
CASE
WHEN (n)-[]-(n1)
THEN "1"
ELSE "0"
END AS result
方法二:返回关系条数
MATCH (n:Test{id:"Q1"}),(n1:Test{id:"Q2"}),p=(n)-[]-(n1)
return count(p)
不存在关系返回0,存在关系返回大于0的数
MATCH (n:Test{id:"Q1"}),(n1:Test{id:"Q2"})
RETURN
CASE
WHEN (n)-[]-(n1)
THEN "1"
ELSE "0"
END AS result
MATCH (n:Test{id:"Q1"}),(n1:Test{id:"Q2"}),p=(n)-[]-(n1)
return count(p)
不存在关系返回0,存在关系返回大于0的数
转载于:https://www.cnblogs.com/Cia-L/p/11353179.html