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.

From node with multiple relationship, get node all relationships connected to a given node

Hi,
I need to get all nodes and relationships related to a given node.
For example, I have a node "Person", and it's related to node "Family", node "City", node "Car" and node "Bank":
Person [PartOf]-> Family
Person [BornIn]-> City
Person [Own]-> Car
Person [CustomerOf]-> Bank

How can I get in a query the Person and all its relationships and related nodes?
Thanks.

3 REPLIES 3

Hello @elad and welcome to the Neo4j community

MATCH path=(:Person)-[]->()
RETURN path

Regards,
Cobra

Thank you @Cobra
I guess I didn't explain myself clearly.
Your query will give me multiple results for each Person, right?
I'm aiming for 1 result for each person.
Let's say I have 5 persons with those links, so I want a query that will return a list of results, each result will be a unique person and its relationships and nodes.
So if I query in my case for a Person and all the relationships and related nodes, I want to get 5 result, and each result will contain all the other nodes.
Thanks.

This query will return for each Person a list of relations and a list of nodes

MATCH (p:Person)-[r]->(n)
RETURN p, collect(r) AS relations, collect(n) AS nodes