所以我有一个节点:Customer
,其中包含许多节点:Order
,而:Order
与:Shipper
节点:SHIP_VIA
的关系必须为1 {}} :
(customer:Customer)-[:PURCHASED]->(order)-[:SHIP_VIA]->(shipper:Shipper)
现在只有3个托运人,订单指向他们,而客户会有很多订单。所以我的问题是如何让所有托运人都附带所有客户?请注意,每个托运人都有一个shipperID
属性。这是我的代码,但它没有工作,除了一个" where exists"
match (customer:Customer)-[:PURCHASED]->(order)-[:SHIP_VIA]->(shipper:Shipper)
WHERE exists((customer)-[:PURCHASED]->(order)-[:SHIP_VIA]->(:Shipper
{shipperID:1})) and exists((customer)-[:PURCHASED]->(order)-[:SHIP_VIA]->
(:Shipper {shipperID:2})) and exists((customer)-[:PURCHASED]->(order)-
[:SHIP_VIA]->(:Shipper {shipperID:3})) return customer, order , shipper;
答案 0 :(得分:0)
答案 1 :(得分:0)
MATCH (shipper:Shipper)
WITH count(shipper) AS totalShippers
MATCH (customer:Customer)-[:PURCHASED]->(order)-[:SHIP_VIA]->(shipper:Shipper)
WITH totalShippers, customer,
COUNT(DISTINCT shipper) as shippers WHERE totalShippers = shippers
RETURN customer