Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-01-2022 03:52 AM
Hi everyone,
I'm trying to use a parametrized query to create my graph.
````:param A => ["AA","AB"];
:param B => ["BA","BB"];
WITH $A as A, [10,30,30,26] as duration
FOREACH (c in A and d in duration| CREATE(:field { name:c, duration:d}));
This query does not work. I have two questions:
1- How to create list of paramters
2- How to iterate through two lists when creating a node
Thank you
Solved! Go to Solution.
11-01-2022 07:43 AM
You can use a double 'unwind' to get the Cartesian product of the two lists, then use 'create' directly.
WITH [10,30,30,26] as duration
UNWIND $A as a
UNWIND duration as d
CREATE(:field { name:a, duration:d})
11-01-2022 07:43 AM
You can use a double 'unwind' to get the Cartesian product of the two lists, then use 'create' directly.
WITH [10,30,30,26] as duration
UNWIND $A as a
UNWIND duration as d
CREATE(:field { name:a, duration:d})
11-01-2022 08:08 AM
Thank you, it works perfectly. How about parameters. any idea please to how declare several list of parameters ?
11-01-2022 08:19 AM
Your welcome...Use 'params' instead, where you can define a map of parameters.
:params {A:["AA","BB"], B:["BA","BB"]}
All the sessions of the conference are now available online