I'm trying to write a cypher query to find the first name of 'Employee' nodes who 'Has' all the Skills (have relationship with all the nodes with the 'Skill' label). This is my data model:

enter image description here

I managed to get all the employee nodes that have at least one relationship with skill nodes, but I do not want this. This is the cypher query:

:match (a:employee)-[r:Has_Skill]->(b:profession) return a,r,band

I couldn't write it with the ALL() function. Can anybody help me with this?


Aside: Your Cypher query uses node labels and relationship types that do not match your illustrated data model. So, I will ignore your illustration.

This is a slightly tricky way to get the employee nodes that have Has_Skill relationships to all profession nodes:

MATCH (p:profession)
MATCH (employee:employee)-[r:Has_Skill]->()
WITH pCount, employee, COUNT(r) AS sCount
WHERE sCount = pCount
RETURN employee;

The query gets the number of profession nodes and returns employees that have that number of skills.

By the way, you will get much better support for neo4j questions at stackoverflow.com.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy