Neo4j CQL RETURN子句用于 -
RETURN
<node-name>.<property1-name>,
........
<node-name>.<propertyn-name>
MATCH (p:Person) RETURN p.name
MATCH (p:Person) RETURN p.name
MATCH (p) RETURN *
MATCH (n {name: 'Jim'})-[r:LIKES]->(c) RETURN r
MATCH (n {name: 'Jim'}) RETURN n.name
MATCH p = (a {name: 'Jim'})-[r]->(b) RETURN *
遇到特殊字符用`符号引起来
MATCH (`This isn\'t a common variable`)
WHERE `This isn\'t a common variable`.name = 'Jim'
RETURN `This isn\'t a common variable`.name
MATCH (a {name: 'Jim'}) RETURN a.age AS SomethingTotallyDifferent
返回
SomethingTotallyDifferent |
---|
55 |
MATCH (n) RETURN n.age
n.age | |
---|---|
1 | null |
2 | null |
3 | null |
4 | null |
5 | null |
6 | null |
7 | null |
8 | 18 |
MATCH (a {name: 'Jim'}) RETURN a.age > 30, "I'm a person", [p=(a)-->() | p] AS `(a)-->()`
我们之前Jim是Likes Lucy 现在增加一个关系 Jim KNOWS Lucy
MATCH (a :Person{name: 'Jim'}),(b :Person {name:'Lucy'}) CREATE (a)-[:KNOWS]->(b)
Neo4j CQL RETURN 这样Jim和Lucy的关系有两条
MATCH (a :Person{name: 'Jim'})-->(b) RETURN DISTINCT b
"b" │
╞═════════════════╡
│{"name":"Lucy"} │
├─────────────────┤
│{"color":"black"}│
├─────────────────┤