Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-31-2022 09:45 PM
Hi all, I am a beginner in Cypher and would like to seek for some help here.
I want to merge two sets of data,one is from database table by using ````match` command,other is import from csv file,so my CQL is below:
Match(u:user) return u.name as name,u.age as age,u.sex as sex,u.job as job order by name union match(o:other) load csv from `'http://location:3434/otherjob.csv' as x return x[0] as name,x[1] as age,x[2] as sex,x[3] as name,x[4] as job
It's works when i was testing on the neo4j brower,but there was an error when I tested in the production environment.the server return.
"message" : "Only one column is supported currently in orderBy param.",
Can anyone can help me why does this error appear and how to fix it?
Thanks all
Solved! Go to Solution.
09-01-2022 04:25 AM
Your cypher statement it effectively
MATCH <clause> RETURN order by UNION MATCH <clause> LOAD CSV <clause> RETURN
which seems awkward. Also, your final return includes
return x[0] as name,x[1] as age,x[2] as sex,x[3] as name,x[4] as job
and here both the 1st column and 4th column are named 'name' which also is not supported.
Can you describe what you want your query to do
09-01-2022 04:30 AM
Thanks for your help.
I wanna combine two sets of data.the CQL code I was written wrong.
return x[0] as name,x[1] as age,x[2] as sex,x[3] as Job
09-01-2022 06:48 AM
I agree with @dana_canzano. The intent of the query is confusing. What do you mean by "combine", as you are not persisting the data from the csv file. You are just reading it and output it each query execution.
Also, what is the purpose of the following match? The query doesn't use the variable 'o' anytime after the match.
match(o:other)
09-01-2022 04:25 AM
Your cypher statement it effectively
MATCH <clause> RETURN order by UNION MATCH <clause> LOAD CSV <clause> RETURN
which seems awkward. Also, your final return includes
return x[0] as name,x[1] as age,x[2] as sex,x[3] as name,x[4] as job
and here both the 1st column and 4th column are named 'name' which also is not supported.
Can you describe what you want your query to do
09-01-2022 04:30 AM
Thanks for your help.
I wanna combine two sets of data.the CQL code I was written wrong.
return x[0] as name,x[1] as age,x[2] as sex,x[3] as Job
09-01-2022 06:48 AM
I agree with @dana_canzano. The intent of the query is confusing. What do you mean by "combine", as you are not persisting the data from the csv file. You are just reading it and output it each query execution.
Also, what is the purpose of the following match? The query doesn't use the variable 'o' anytime after the match.
match(o:other)
09-01-2022 07:01 AM
Thanks @dana_canzano @glilienfield
The ‘combine’ means data A+data B,I don’t know how to query the result which contain the data from user and csv file in one CQL command.I just only know the
MATCH <clause> RETURN order by UNION MATCH <clause> LOAD CSV <clause> RETURN
This match is just trying to make this code work(load csv from)
match(o:other)
09-01-2022 08:42 AM - edited 09-01-2022 08:43 AM
hum...If you want the data from the spreadsheet to be added to the database, you need to write a query for that. You can then query for all the data you want after persisting the csv data. As you have it now, you are just reading the csv file and outputting from the query. You can try a query like the following to persist the csv data:
load csv from 'http://location:3434/otherjob.csv' as x
with x[0] as name, x[1] as age, x[2] as sex, x[3] as job
merge(n:user{name: name})
set n.age = age, n.sex = sex, n.job = job
Now, executing the following query you will get all the data, which includes the imported csv data:
match(u:user)
return u.name as name, u.age as age, u.sex as sex, u.job as job
order by name
Is this what you are looking for?
All the sessions of the conference are now available online