Armen Arzumanyan Armen Arzumanyan - 3 months ago 11
Java Question

Neo4j: delete relationship between 2 nodes Neo.ClientError.Statement.SyntaxError

I have cypher query which should delete relationship between 2 nodes

MATCH (t:User) - [r:LINKED_TO] - (p:Movie)
WHERE ID (t) = {0}, ID (p) = {5}
DELETE r
RETURN r, t


after run I have error like


Invalid input ',': expected whitespace, '.', node labels, '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, CALL, RETURN, UNION, ';' or end of input (line 1, column 67 (offset: 66))


What is the problem? I can not fix it:(

Answer

You need to specify the second term in your where clause with AND. Also, once you get pas that you would have an error trying to return r - after all, you just deleted it :)

MATCH (t:User) - [r:LINKED_TO] - (p:Movie) 
WHERE ID (t) = {0}
AND ID (p) = {5} 
DELETE r 
RETURN t,p
Comments