Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-02-2020 12:15 AM
Hi,
I have a query like below
Match (n1:Node A)<-[:hasData]-(n2:CommonNode)-[:hasValue]->(n3:Node3) where ID(n3) = '<node_id>' and ID(n2) = '<node_id>' with n3.name as n3_name,n1.name as n1_name CASE n3_name WHEN [] THEN n1_name ELSE n3_name END as key return key
In the above query I have a Common Node which has nodes on either side.Based on the values from the nodes on both sides of Common Node I have to perform another operation so I got the values from both the nodes in WITH and using CASE returned the key.Used CASE because i have to perform another operation if node n3 has value else i have to use the value of node n1.
In the above case I'm getting the below error
Neo.ClientError.Statement.SyntaxError: Invalid input 'S': expected 'l/L' (line 2, column 3 (offset: 435))
My question is can we use CASE followed by WITH?
Thanks,
Saravanan.
Solved! Go to Solution.
08-02-2020 12:31 AM
Solved the above mentioned
Match (n1:Node A)<-[:hasData]-(n2:CommonNode)-[:hasValue]->(n3:Node3) where ID(n3) = '<node_id>' and ID(n2) = '<node_id>' with (CASE n3_name WHEN [] THEN n1_name ELSE n3_name END) as key return key
On getting the node values in WITH we have to use CASE within WITH and return the values.
Thanks
Saravanan.
08-02-2020 12:31 AM
Solved the above mentioned
Match (n1:Node A)<-[:hasData]-(n2:CommonNode)-[:hasValue]->(n3:Node3) where ID(n3) = '<node_id>' and ID(n2) = '<node_id>' with (CASE n3_name WHEN [] THEN n1_name ELSE n3_name END) as key return key
On getting the node values in WITH we have to use CASE within WITH and return the values.
Thanks
Saravanan.
All the sessions of the conference are now available online