I’m trying to implement two sequential pairs of (MATCH, SET) as in following code, please note that the example below can be replaced with one (MATCH, SET) pair as the example is just for demonstration purposes, but in my situation two sequential pairs is a must:
SELECT * FROM cypher('test', $$
MATCH (a: person {name:'yousef'}) SET a.name = 'yousef222' RETURN n.name MATCH(b:person {name: 'mostafa'}) SET b.name = 'mostafa222' RETURN a.name ,b.name
$$) as (a_name agtype, b_name agtype);
when I run the query I get the following error:
ERROR: syntax error at or near "MATCH"
LINE 2: ...name:'hla'}) SET n.name = 'hlaaaa' RETURN n.name MATCH(b:pe...
^
How can I resolve the issue while maintaining the two sequential pairs?
3
Answers
You need to use the
WITH...AS
clause like so:The synatax error you encountered was because you used
n.name
andn
was not defined in the query,but you can implement two sequential pairs of (MATCH/SET) by modifying your query as follows:
Hope this helps.
Here issue is with query that you are trying to use MATCH-SET pair in a single pair. You can only have single MATCH clause for single return therefore split your query in two separate cypher.
similar write another one like this