Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Matching full list of children of parent with condition on one

I have two NodeType: Parent and Child and a relation : HAS_CHILD

Each Child has a name.

Each parent has many children.
I need to retrieve all children of a parent if this parent has a child matching a certain name.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So far I only succeed to retrieve the Parents and the children matching the name, but I need all the children of these parents.

MATCH (p:Parent)-[HAS_CHILD]->(c:Child) WHERE toLower(c.name) = 'Alex'
RETURN p, c

>Solution :

Now that you have all the parents that have a child with the name ‘Alex` (these are nodes p), you can use them to get their children:

MATCH (p:Parent)-[:HAS_CHILD]->(c:Child)
WHERE toLower(c.name) = 'alex'
WITH p
MATCH (p)-[:HAS_CHILD]->(c:Child)
RETURN p, c
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading