Neo4J - Creating a relationship to existing nodes

I am new to Neo4J and I am looking to create a new relationship between an existing node and a new node.

I have a university node and a person node.

I am trying to appoint a new person to an existing university.

I am trying to execute the following code:

MATCH (p:Person {name:'Nick'}), (u:University {title:'Exeter'}) CREATE (p)-[:LIKES]->(u)

So, in the above code: MATCH (p:Person {name:'Nick'})- new user

And (u:University {title:'Exeter'})is an existing university.

But he is returning (no changes, no rows)

I even tried the query without the MATCH part, but no luck.

I looked at a few similar answers, but they didn't seem to work either.

Any help would be greatly appreciated. Thanks.

+4
source share
3 answers

, !

MATCH(u:University {title:'Exeter'})
CREATE(p:Person {name:'Nick'})
CREATE(p)-[w:LIKES]->(u)
return w
+8

MERGE docs:

MERGE , , . MATCH CREATE, , , .

MERGE (p:Person {name:'Nick'})-[:LIKES]->(u:University {title:'Exeter'})
+1

, db. , " ".

, - , + , , . merge 'node1' merge'node2 'create (node1) [] → (node2)

0

Source: https://habr.com/ru/post/1625753/


All Articles