cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple title rows returned for a single acted Movie node

Hi,
I am going though cypher learning exercises.
I ran a below query and was expecting a single return row.

MATCH (p:Person)-[ACTED_IN]->(m:Movie)
WHERE p.name = 'Tom Hanks' and m.title = 'That Thing You Do'
RETURN m.title

RESULT
╒═══════════════════╕
│"m.title" │
╞═══════════════════╡
│"That Thing You Do"│
├───────────────────┤
│"That Thing You Do"│
└───────────────────┘

wherein below query brings single movie node only

MATCH (p:Person)-[ACTED_IN]->(m:Movie)
WHERE p.name = 'Tom Hanks' and m.title = 'That Thing You Do'
RETURN m

is my expectation or understanding wrong? Can someone help me understand this behavior with some pointers?
Thanks in advance.

-Puneet

4 REPLIES 4

ameyasoft
Graph Maven
Try this:
RETURN distinct m.title

Thanks. That will work.
I am trying to understand the logic of at the first place why/how it brings 2 entries, wherein it should only bring 1 entry as we are matching for ACTED_IN relationship only.

Tom Hanks is the director of this movie and also acted in.

That's true, but I am matching only ACTED_IN relationship. Shouldn't this only bring one row by excluding DIRECTOR relationship? Please let me know how match and return works overall logically here, that will help clear my doubt.

Thanks.