Cypher queries examples

INSERT
CREATE (diana:Person {name: “Diana”})
CREATE (melissa:Person {name: “Melissa”, twitter: “@melissa”})
CREATE (xyz:Company {name: “XYZ”})
CREATE (diana)-[:WORKS_FOR]->(xyz)
CREATE (diana)-[:IS_FRIENDS_WITH]->(melissa)

UPDATE
MATCH (p:Person {name: ‘Diana’}) SET p.birthdate = date(‘1980-01-01’)
MATCH (:Person {name: ‘Diana’})-[rel:WORKS_FOR]-(:Company {name: ‘XYZ’}) SET rel.startYear = date({year: 2018})

DELETE
MATCH (j:Person {name: ‘Diana’})-[r:IS_FRIENDS_WITH]->(m:Person{name: ‘Melissa’}) DELETE j,r,m

SELECT
MATCH (p:Product) RETURN p.productName, p.unitPrice ORDER BY p.unitPrice DESC LIMIT 10;

Leave a Reply

Your email address will not be published. Required fields are marked *