Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-05-2022 03:06 PM
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
01-05-2022 04:10 PM
Try this:
RETURN distinct m.title
01-05-2022 06:18 PM
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.
01-05-2022 11:38 PM
Tom Hanks is the director of this movie and also acted in.
01-06-2022 08:20 AM
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.
All the sessions of the conference are now available online