cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Exercise 3.3 CODE HELP

Looking to create code for Exercise 3.3 for the below question:

*** Retrieve all people connected with a particular movie.**

Inputted the below code but received an error

MATCH (p:Person)->(:Movie {title:"A League of their Own"}) Return p

What am I doing wrong?

Thank you to anyone who can help

4 REPLIES 4

mdfrenchman
Graph Voyager

Missing a second - in the rel. —> vs ->
Can also leave off the arrow to potentially grab relationships that go the other direction. I haven’t touched that dataset in a while so that may not make a difference in the result.

Best of luck!

Thank you very much! I will test this out.

To clarify, when you only want to capture any relationship, but don't need to know it's type, properties, and you don't need variable-length relationships, and you don't need a variable on it, then two dashes are needed in the pattern:

(p:Person)-->(:Movie {title:"A League of their Own"})

This is because normally you would have something in the middle, such as the relationship type:

(p:Person)-[:ACTED_IN]->(:Movie {title:"A League of their Own"})

So when none of that is needed, everything in the square brackets can be dropped (along with the square brackets themselves) leading you just to the two dashes and direction (provided the direction is needed).

Thank you very much for this! I will try these solutions.