Using WITH to scope variables
Update this query to use a WITH
clause to create a variable for the actor’s name.
cypher
?????? 'Tom Hanks' AS ??????
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE p.name = ??????
RETURN m.title AS title
Answer this question:
How many movies did Tom Hanks star in?
How many movies titles are returned?
-
✓ 38
Hint
You will need to use WITH
to scope the variable for the actor’s name.
The keyword AS
is used to create an alias for the variable.
Solution
The answer is 38
.
Run the following query to see the result:
cypher
WITH 'Tom Hanks' AS theActor
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE p.name = theActor
RETURN m.title AS title
Summary
In this challenge, you modified a query to use a WITH
clause to limit and order nodes.
In the next challenge, you will answer another question about this query.