0
votes

Neo4j query for movie database NOT in Query Neo4j - NOT IN query

MATCH (actor:Actor {name:"Tom Hanks"} )-[:ACTED_IN]->(movies)<-[:ACTED_IN]-(coactor)
WITH collect(distinct coactor) as coactors
MATCH (actor:Actor)
WHERE actor NOT IN coactors
RETURN actor

While running this query I got Error:

Invalid input 'N': expected whitespace, comment, node labels, MapLiteral, a parameter, a relationship pattern, '(', '.', '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, RETURN, UNION, ';' or end of input (line 4, column 13 (offset: 160)) "WHERE actor NOT IN coactors"

2

2 Answers

2
votes

I believe that's a small mistake in their example query.

WHERE actor NOT IN ...

is incorrect syntax (though I wouldn't mind a Cypher update to allow it). It should be

WHERE NOT actor IN ...
0
votes

InverseFalcon has the correct answer, but note that the parser tells you exactly where the error is: line 4, column 13.

WHERE actor NOT IN coactors
            ^

It also tells you what can be expected at that point (including IN), and that doesn't include NOT.