Neo4j graph database commonly used CQL

1. Create a node

CREATE (m4:mail_list { name:"李一",gender:"男",ethnic:"汉",cardid:123456789,domicile:"山西太原"})
CREATE (m4:mail_list {id:"1",name:"李二",gender:"女",ethnic:"回",cardid:958545545225554,domicile:"山西太原小店区"})

2. Create a relationship

match(p1:mail_list),(p2:mail_list)
where p1.name="李一" and p2.name = "李二"
create (p1) -[suspect:suspect{relation:"亲戚"}]-> (p2);

3. Query the mail_list label

MATCH (n:mail_list) RETURN n

4. Paging query

MATCH (n:mail_list) RETURN n SKIP 2  LIMIT 25

5. Query the shortest relationship between two nodes

match a = allshortestPaths((n:mail_list{name:"李静"})-[*]-(m:mail_list{name:"吴高辉"})) return a

6. Find all relationships between two nodes with a depth of 2

match (n:mail_list{name:"李静"})-[*]-(m:mail_list{name:"吴高辉"}) return (n)-[*2]-(m) as p

7. Query all relationships between two nodes

match a = (n:mail_list{name:"李静"})-[*]-(m:mail_list{name:"吴高辉"}) return a

8. Query all relationships of the specified node

match a = (n:mail_list)-[]-() where n.name =~".*李.*" return a

9. Delete tags and all relationships

MATCH (n:mail_list)-[r]-() DELETE n,r

 

Guess you like

Origin blog.csdn.net/qq_26875961/article/details/93711831