create (s:Student {name:'Jack'}),
(t:Teacher {name: 'Mary', age: '30'}),
(s)-[r:has_teacher]->(t)
如何制作此Cypher查询问题:
找到杰克老师的名字,答案应该是'玛丽'。
答案 0 :(得分:1)
考虑到评论中的要求,您可以忽略教师姓名为null
的模式:
MATCH (s:Student)-[r:has_teacher]->(t:Teacher)
where s.name = "Jack" and t.name is not null
return t.name;
在某些情况下,您可能只想查询:Teacher
个节点具有name
属性的模式:
MATCH (s:Student)-[r:has_teacher]->(t:Teacher)
where s.name = "Jack" and EXISTS(t.name)
return t.name;
答案 1 :(得分:0)
试试这个:
MATCH (s:Student)-[r:has_teacher]->(t:Teacher) where s.name = "Jack" return t.name;