这是我对Neo4j数据库的Py2neo的查询
MATCH (u:User),(p:Prize),(ca:Category) CREATE (ch:Challenge {chid:'dassdshhhhasdasda',challenge_title:'Exm 2015', total_question_per_user:200,challenge_status:1,timestamp:'1471516538.4643',date:'2016-08-18'}), (p)-[:BELONG {rank:3}]->(ch),(ca)-[:BELONG {percentage_question:20}]->(ch) WHERE u.username = 'xyz@gmail.com' AND p.pid = 'e766d8cd-26d1-4848-ac97-15c233caa4d4' AND ca.catname = 'nature'
但是当我在Neo4j数据库命令行中手动运行它然后显示错误
Invalid input 'H': expected 'i/I' (line 1, column 287 (offset: 286))
"MATCH (u:User),(p:Prize),(ca:Category) CREATE (ch:Challenge {chid:'dassdshhhhasdasda',challenge_title:'Exm 2015', total_question_per_user:200,challenge_status:1,timestamp:'1471516538.4643',date:'2016-08-18'}), (p)-[:BELONG {rank:3}]->(ch),(ca)-[:BELONG {percentage_question:20}]->(ch) WHERE u.username = 'xyz@gmail.com' AND p.pid = 'e766d8cd-26d1-4848-ac97-15c233caa4d4' AND ca.catname = 'nature'"
我想使用WHERE
子句,不使用WHERE
我像这样运行此查询然后运行
MATCH (u:User {username:'xyz@gmail.com'}),(p:Prize{pid:'e766d8cd-26d1-4848-ac97-15c233caa4d4'}),(ca:Category {catname:'nature'}) CREATE (ch:Challenge {chid:'dassdsdjgjasdasdasda',challenge_title:'Exm 2015', total_question_per_user:200,challenge_status:1,timestamp:'1471516538.4643',date:'2016-08-18'}), (p)-[:BELONG {rank:3}]->(ch),(ca)-[:BELONG {percentage_question:20}]->(ch)
答案 0 :(得分:1)
您在错误的位置使用WHERE
子句。 where子句需要与MATCH
语句结合使用,而不是CREATE
。
像这样......
MATCH (u:User),(p:Prize),(ca:Category)
WHERE u.username = 'xyz@gmail.com'
AND p.pid = 'e766d8cd-26d1-4848-ac97-15c233caa4d4'
AND ca.catname = 'nature'
CREATE (ch:Challenge {chid:'dassdshhhhasdasda',
challenge_title:'Exm 2015',
total_question_per_user:200,
challenge_status:1,
timestamp:'1471516538.4643',
date:'2016-08-18'})
,(p)-[:BELONG {rank:3}]->(ch)
,(ca)-[:BELONG {percentage_question:20}]->(ch)