How can duplicate results in a different order be removed in a Cypher response?

后端 未结 1 1406
终归单人心
终归单人心 2021-01-24 01:13

I am trying to find all the videos which 2 people commonly liked using the following cypher query

MATCH (p1: person)-[:LIKED]->(v)<-[:LIKED]-(p2: person)
r         


        
相关标签:
1条回答
  • 2021-01-24 01:50

    Here is one way to prevent duplicate results:

    MATCH (p1: person)-[:LIKED]->(v)<-[:LIKED]-(p2: person)
    WHERE ID(p1) < ID(p2)
    RETURN p1, p2, v;
    

    This works by requiring p1 to have a lower native ID than p2.

    0 讨论(0)
提交回复
热议问题