2
votes

MATCH (a)-[:PRODUCED]->(b) RETURN a

  • It's displaying 8 nodes. Its ok. But when i am going to return it's properties it's displaying duplicate values.

MATCH (a)-[:PRODUCED]->(b) RETURN a.name

  • It's returning 15 rows. According to me as (a) is related with (b) 15 times and thats why its returning duplicate record but I don't need that. I need only unique 8 rows.

How will I do that or what will be the exact cypher query?

1

1 Answers

2
votes

You have a couple of options, I think:

MATCH (a)-[:PRODUCED]->(b) RETURN DISTINCT a.name

or

MATCH (a)-[:PRODUCED]->(b) WITH a RETURN a.name

The former returns distinct names, which isn't good if you have multiple nodes with the same name and you want that result returned. The later should pass on the set of distinct nodes and then return their names. If that doesn't work, you could try WITH DISTINCT a