Neo4j (installation url)

Note:An error is reported in your computer execution, possibly the node has not been created.

CREATE


-Create a node with no attributesCREATEEmp :Employee # emp is a node name. Employee is the label name of the EMP node.-Create a node with attributesCREATE (dept:Dept { deptno:10,dname:"Accounting",location:"Hyderabad"}) # dept is a node name. Dept is the label name of the EMP node. Inside the braces is the data for Dept-Create multiple labels to the nodeCREATE(m: Movie: Cinema: Film: Picture) # m is a node name here, the Movie, the Cinema, the Film, the Picture is m node multiple tag name-Create multiple nodes with relationships (no attributes) (no attributes)CREATE (fb1:FaceBookProfile1)-[like:LIKES]->(fB2 :FaceBookProfile2) # LIKESlike"-Create multiple nodes with relationships (with attributes) (with attributes)CREATE (video1:YoutubeVideo1{title:"Action Movie1",updated_by:"Abc",uploaded_date:"10/10/2010"})-[movie:ACTION_MOVIES{rating:1}]->(video2:YoutubeVideo2{title:"Action Movie2",updated_by:"Xyz",uploaded_date:"12/12/2012"}) 

Copy the code

MATCH with the RETURN

-Querying node ContentMATCH (dept:Dept) returnDept # query the contents of deptMATCH (p:Employee {id:123,name:"Lokesh"}) RETURNP # select id from Employee=123The name,="Lokesh" nodeMATCH (p:Employee) WHERE p.name = "Lokesh" RETURNSelect * from Employee where Employee = Employee="Lokesh" node, using (whereCommand, analogysql)-Querying node RelationshipsMATCH (cust)-[r:DO_SHOPPING_WITH]->(cc) RETURNCust, CC # The relationship name is "DO_SHOPPING_WITH" and the relationship label is "R". If an error is reported, the CUST, CC may not be created-Query and create node relationshipsMATCH (e:Customer),(cc:CreditCard)  CREATE (e)-[r:DO_SHOPPING_WITH ]->(cc) # relationship name "DO_SHOPPING_WITH" relationship tag "r", relationship is e->C) the relationship has no attributesMATCH (cust:Customer),(cc:CreditCard) CREATE (cust)-[r:DO_SHOPPING_WITH{shopdate:"12/12/2014",price:55000}]->(cc) RETURNR # Relationship name is "DO_SHOPPING_WITH" relationship label is "R" and relationship is "e"->C, the relationship has properties shopdate and price.Copy the code

WHERE

-Query and create node relationshipsMATCH (cust:Customer),(cc:CreditCard) WHERE cust.id = "1001" AND cc.id= "5001" CREATE (cust)-[r:DO_SHOPPING_WITH{shopdate:"12/12/2014",price:55000}]->(cc) RETURN r

Copy the code

DELETE


-Remove nodesMATCH (e: Employee) DELETE e

- DELETENodes and relationshipsMATCH (cc: CreditCard)-[rel]-(c:Customer) DELETE cc,c,rel

Copy the code

REMOVE

-Remove nodes/Relationship betweenMATCH (book { id:122 }) REMOVE book.price RETURNThe book # "Price" property was removed-Remove the labelMATCH (m:Movie) REMOVE m:Picture

Copy the code

SET

-Updated node attribute valuesMATCH (book:Book) SET book.title = 'superstar' RETURN book

Copy the code

Sorting

-Sort by node attribute (ascending order)MATCH (emp:Employee) RETURN emp.empid,emp.name,emp.salary,emp.deptno ORDER BY emp.name ASC
MATCH (emp:Employee) RETURN emp.empid,emp.name,emp.salary,emp.deptno ORDER BY emp.name DESC
Copy the code

UNION

-Joint Query (UNION: Combines common rows from two sets of results and returns them to one set of results. It does not return duplicate rows from two nodes.MATCH (cc:CreditCard) RETURN cc.id as id,cc.number as number,cc.name as name, cc.valid_from as valid_from,cc.valid_to as valid_to UNION MATCH (dc:DebitCard) RETURN dc.id as id,dc.number as number,dc.name as name,dc.valid_from as valid_from,dc.valid_to asValid_to # queries should have the same column name-Joint Query (UNION ALL: Combines common rows from two sets of results and returns them to one set of results. It returns repeated rows from both nodes.MATCH (cc:CreditCard)RETURN cc.id as id,cc.number as number,cc.name as name,cc.valid_from as valid_from,cc.valid_to as valid_to UNION ALL MATCH (dc:DebitCard) RETURN dc.id as id,dc.number as number,dc.name as name, dc.valid_from as valid_from,dc.valid_to asValid_to # queries should have the same column nameCopy the code

LIMIT and SKIP

-LIMIT number (LIMIT)MATCH (emp:Employee) RETURN emp LIMIT 2Take the first two lines-LIMIT number (LIMIT)MATCH (emp:Employee) RETURN emp SKIP 2# take the last two linesCopy the code