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 Dynamic Relationship between multiple columns

Hi,

I have a CSV which has data about multiple types of nodes and the type of relationship between the nodes. Here I have to create a dynamic relationship between the nodes, which I got the ans. Since there are data about multiple types of nodes and their relationship I am not able to call multiple apoc.create.relationship in a single query like


I am getting an error as

I know I can go with multiple queries, but I am curious to know if I can do it in one query.

Thanks in advance.

3 REPLIES 3

You can do it together, you need an intermediate WITH though. Something like this:

CALL apoc.create.relationship(m, rele_1, {}, m) yield rel
WITH rel, m, rele_2, o
CALL apoc.create.relationship(m, rele_2, {}, o) yield rel
return rel;

Hie, Thanks a lot for the response, it worked. Well we don't need "rel" in "WITH" as throws error.

I've been writing cypher for years and I frequently forget to "carry through the right variables" in my WITH clauses to ensure the clause beneath has what it needs. 😉 Some fiddling is expected -- you've got the right idea