我想在查询下面找到唯一的结果表单。我想要为同一事件(即m)或宗教信仰注册的结果。我不想要双重结果。当n和o来自同一个宗教并注册同一事件时,这个查询给我重复的结果。除了结合之外还有其他方法。
start o=node(1) match o-[rt:Has_Matrimony]-x1,(n:Woftos_Profile),o-[re:Registered_For]-m,t<-[r:Registered_For]-n-[r1:Has_Matrimony]->p WHERE p.Status='Active' AND n.Gender <> o.Gender and re.Status='Active' and r.Status='Active' and p.Status='Active' and m.Name=t.Name and id(o)<>id(n) return DISTINCT
id(p),id(n),n.Age,collect(id(t))[0..2] as eventtlist ,p.Package order by n.Age limit 5
UNION START o=node(1) match (n:Woftos_Profile),n-[r:Has_Matrimony]-p,(t:WF_Community_Event) WHERE o.Religion=n.Religion and id(o)<>id(n) optional match n-[rt:Registered_For]-m,(o)-[rrt:Registered_For]->m where rt.Status='Active' and rrt.Status='Active' and m.Name<>t.Name and NOT ((o)-[rrt:Registered_For]->t)
return DISTINCT id(p),id(n),n.Age,collect(id(m))[0..2] as eventtlist,p.Package order by n.Age limit 5