我正在尝试查询以下内容:
列出在其注册的课程中至少有一个A的学生的姓名。(不要将A-视为A。)
Image of the schema for my database
我使用以下查询:
MATCH (studentPerson)<-[:S2P]-(:Student)-[:Taking]->(:Offering)-
[:Covers]->(studentCourse)
WHERE studentCourse.Grade = "A"
RETURN studentPerson.Name as student
但每次我运行它,我都会继续#34;(没有变化,没有记录)&#34;。
我也尝试使用EXISTS(studentCourse.Grade = "A")
无济于事。
当记录添加到数据库时,它们是从如下文件中添加的:
match (a:Student), (b:Offering) where a.ID = 419180204 and b.ID = 15
create (a) - [r:Taking{EnrollmentID:'Enrollment306',Grade: 'A-'}]-> (b)
WITH count(*) as dummy
match (a:Student), (b:Offering) where a.ID = 449976666 and b.ID = 15
create (a) - [r:Taking{EnrollmentID:'Enrollment307',Grade: 'C+'}]-> (b)
WITH count(*) as dummy
match (a:Student), (b:Offering) where a.ID = 477453864 and b.ID = 15
create (a) - [r:Taking{EnrollmentID:'Enrollment308',Grade: 'A'}]-> (b)
WITH count(*) as dummy
match (a:Student), (b:Offering) where a.ID = 495490053 and b.ID = 15
create (a) - [r:Taking{EnrollmentID:'Enrollment309',Grade: 'A-'}]-> (b)
是否可能由于实体被添加到关系中(&#34; r:Take&#34;),“提供”节点甚至没有成绩?
我是neo4j
的全新品牌并且尽力而为,但到目前为止这件事让我很困惑。
感谢任何帮助。
答案 0 :(得分:0)
问题是Grade
是:Taking
关系的属性。因此,在您的查询中,将变量添加到该关系类型,例如(:Student)-[t:Taking]->(:Offering)
并使用t.Grade = 'A'
进行过滤:
MATCH (studentPerson)<-[:S2P]-(:Student)-[t:Taking]->(:Offering)-
[:Covers]->(studentCourse)
WHERE t.Grade = `A`
RETURN studentPerson.Name as student