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.

Creating new relationship based on another relationship

Hello, how are you?

Guys, I am new on neo4j, so I need a lot of help. At this momment I am trying to create a relationship between two nodes and I am receiving a messa error. To the first match I am basing on a existin relationship. I think that this is my mistake. Bellow is my code:

MATCH (po:PessoaOrigem {COD_CAMPO_PK_LEGADO_01: '1'})-[GOLDEN]->(pu:PessoaUnica) return pu
MATCH (c:ContratoOrigem {COD_CAMPO_PK_LEGADO_01: '110'}) return c
MERGE (pu)-[:POSSUI_CONTRATO]->(c);

Now the error message :
RETURN can only be used at the end of the query (line 1, column 82 (offset: 81))
"MATCH (po:PessoaOrigem {COD_CAMPO_PK_LEGADO_01: '1'})-[GOLDEN]->(pu:PessoaUnica) return pu"

Regards,
Igor Martins

2 REPLIES 2

@igorbmartins

as the error states RETURN can only be used at the end of the query. do you want to change your cypher to

MATCH (po:PessoaOrigem {COD_CAMPO_PK_LEGADO_01: '1'})-[GOLDEN]->(pu:PessoaUnica) return pu
MATCH (c:ContratoOrigem {COD_CAMPO_PK_LEGADO_01: '110'}) 
MERGE (pu)-[:POSSUI_CONTRATO]->(c)
return c;

Thank you my friend.. It works fine!
Regards, Igor Martins