我想为下面的图写一个查询,它应该返回三个列表,每个列表都包含为同一个人工作的所有人。
给定下图,结果应该是以下三个列表:
-
[Fritz]
-
[Pepe]
-
[Sussy,Peter]
我没能写出这样的疑问。我的查询返回一个列表中的所有员工。
以下语句为我给出的示例创建了图形模型:
MATCH (c:Example) DETACH DELETE c;
CREATE (p1:Parent:Example {id: 1, name: 'Andy', title: 'Developer'});
CREATE (p2:Parent:Example {id: 2, name: 'Lila', title: 'Developer'});
CREATE (p3:Parent:Example {id: 3, name: 'Lula', title: 'Developer'});
CREATE (c11:Child:Example {id: 11, name: 'Peter', title: 'Developer'});
CREATE (c12:Child:Example {id: 12, name: 'Susy', title: 'Developer'});
CREATE (c21:Child:Example {id: 21, name: 'Fritz', title: 'Developer'});
CREATE (c31:Child:Example {id: 31, name: 'Pepe', title: 'Developer'});
MATCH (p {id: 1}), (c {id: 11}) MERGE (p)<-[:WORKS_FOR]-(c);
MATCH (p {id: 1}), (c {id: 12}) MERGE (p)<-[:WORKS_FOR]-(c);
MATCH (p {id: 2}), (c {id: 21}) MERGE (p)<-[:WORKS_FOR]-(c);
MATCH (p {id: 3}), (c {id: 31}) MERGE (p)<-[:WORKS_FOR]-(c);