How to return the results from this task in Neo4J Cypher?
I am new to neo4j cypher and I would like to solve this query:
"Write a Cypher query that finds the actors that act in the same show and have the same age, when both actors never acted in any other show."
This is my attempt:
MATCH (a: Person)-[acted:ACTED_IN]->(m:Movie)<-[coacted:ACTED_IN]-(b:Person)
WITH a, COUNT(acted) AS num1, b, COUNT(coacted) AS num2
WHERE num1 = 1 AND num2 = 1 AND a.born = b.born
RETURN a.name, b.name
However, as you can see from the picture, the actors that I return have acted also in other shows, whereas the task wants me to get only those actors and coactors that both have the same age and both never acted in any other show before.
Any help?
Solution 1:
The query is correct. It is only in the visualization that Tom Hanks (1956) and Bill Paxson (1955) and Julia Roberts (1967) are connected on the graph. However, if you click on Table or Text on the left column, you will see that Tom Hanks is on the same row with Geena Davis (1956), Nathan Lane (1956) and Rita Wilson (1956). BUT you will not see Tom Hanks and Bill Paxson nor Tom Hanks and Julia Roberts on the same row.