简体   繁体   中英

How to MATCH and CREATE a node and relationship?

Learning Neo4j and need help with getting the basics right. I am trying to find a Matching candidate then create a company and create a relationship between candidate and the newly created company. So, my query is

MATCH (b:Candidate {name:'Bala'}), CREATE (e:Employer {name:'Yahoo'}),
CREATE (b)-[:WORKED_IN]->(e)
RETURN b,e;

Invalid input '(': expected whitespace, comment, '=', node labels, MapLiteral, a parameter, a relationship pattern, ',', USING, WHERE, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, RETURN, UNION, ';' or end of input...

I am using 2.2.5 console.

Remove the two commas before CREATE . The clauses in Cypher are not comma separated, only elements within a clause are. Your query will read

MATCH (b:Candidate {name:'Bala'})
CREATE (e:Employer {name:'Yahoo'})
CREATE (b)-[:WORKED_IN]->(e) 
RETURN b,e;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM