cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Getting a syntax error I don't understand

MuddyBootsCode
Graph Steward

I'm using the latest versions of neo4j desktop and database. I'm doing some development locally and using this query:

match (w:Well)
where w.operator is not null
with w.operator as well_o
merge (o:Operator {name: well_o})
set (o)-[:OPERATES]->(w)
return o, w

I'm getting this error:

Neo.ClientError.Statement.SyntaxError: Invalid input 'r': expected whitespace, comment, a relationship pattern or '.' (line 6, column 1 (offset: 129))
"return o, w"
 ^

If I run the first half of the query it creates the operator nodes no problem. Am I running too many operations in one go? I'm not quite sure what else it's expecting.

1 ACCEPTED SOLUTION

Brrr.. Poor me.

match (w:Well)
match (o:Operator)
where w.operator = o.name
MERGE (o)-[r:OPERATES]->(w)
return r

SET is for putting property or labels
Replace MERGE by MATCH if you don't want create the relationship.

View solution in original post

8 REPLIES 8

Hi !

Must be:
{name: "well_o"}

With quotes.

MuddyBootsCode
Graph Steward

Thanks for the reply, I appreciate the help but that did not work. I'm still getting the same error as before.

I was able to return the pairs I wanted to return with:

match (w:Well)
match (o:Operator)
where w.operator = o.name
return o, w

but if I try to set a relationship between them I get errors.

match (w:Well)
match (o:Operator)
where w.operator = o.name
set(o)-[r:OPERATES]->(w)
return r

Brrr.. Poor me.

match (w:Well)
match (o:Operator)
where w.operator = o.name
MERGE (o)-[r:OPERATES]->(w)
return r

SET is for putting property or labels
Replace MERGE by MATCH if you don't want create the relationship.

MuddyBootsCode
Graph Steward

Ah, you just reminded me what I was really trying to do. You're a prince among men. Here's what I was really after, I just forgot exactly how.

match (w:Well)
match (o:Operator)
where w.operator = o.name
CREATE (o)-[r:OPERATES]->(w)
return r

I forgot to use Create vs. Merge and set. Thank you for your help.

CREATE p=(MATHI{name:"SRIMATHI"})-[r:topper_of]-[]->(TAMIL{name :"TAMILNADU"})-[]->[r:winner_of]-[*]->(cse{name:"ANNA UNIVERSITY IN CSE DEPT"})
RETURN p

i dont get whats the error

Remember, you need to be explicit when you'are creating nodes. Or you give some empty types for relationships ( --> and star (-[*]->).

MuddyBootsCode
Graph Steward

Welcome Joyous,

Do you might adding what error your getting? It's difficult helping without knowing what you're getting.