【问题标题】:NEO4j Cypher query returning distinct valueNEO4j Cypher 查询返回不同的值
【发布时间】:2014-05-21 10:51:39
【问题描述】:

大家好,我是密码查询的新手,我想限制结果中的重复值

查询是

match (ee:Personal {id:"id"})-[:Friend]->(fr),
 (fr)-[:Friend]->(fr2),
 (fr2)-[:Friend]->(friend:Personal),
 (friend)-[:Works]->(comp:Company) 

where comp.name=~".*name.*" 
and not friend.id="id" 
and not (friend)-[:Friend]-(fr) 
and not (friend)-[:Friend]-(ee) 
and not (fr2)-[:Friend]-(ee) 

optional match (comp)-[:Position]->(pos), 
 (friend)-[:Position]->(pos)  
optional match (friend)-[:Location]->(loc) 

return distinct  friend.name,  comp.name

但我得到重复的值,因为在 return statemnt 中有多个节点属性。如果我只返回一个属性,那么它很好。但我想要不同的朋友

【问题讨论】:

    标签: neo4j cypher


    【解决方案1】:

    Distinct 适用于整行,如果您想为每个公司返回不同的朋友,请执行以下操作:

    return comp.name, collect(distinct friend.name)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-15
      • 2023-01-28
      • 1970-01-01
      相关资源
      最近更新 更多