match(a:Person{name:"Tom"})-[lv]->(b:Person{name:"alicy"})delete a,lv; -- 删除节点
match (a:Movie) delete a;-- 删除Tom节点以及它的所有关系match (p:Person{name:'Tom'}) -[lv]-(m) delete p,lv; -- 为alicy 添加性别属性match (p:Person{name:"alicy"}) set p.sex='女' return p;match (p:Person{name:"alicy"}) set p.job='主播' return p;
-- 把alicy的职业移除match (p:Person{name:"alicy"}) remove p.job return p;
-- 按照名字排序
match (p:Person) return p.name ORDER BY p.name desc;
-- union
match (a:Person{name:"alicy"})return a.name union all match(b:Person{name:"Tom"}) return b.name; 这种写法是不行的
从报错中可以得到必须要相同的列名,虽然我们看着相同,但是编辑器不认识,所以加上一个别名
match (a:Person{name:"alicy"}) return a.name as name union all match(b:Person{name:"Tom"}) return b.name as name;
-- limit
match (a:Person) return a LIMIT 1; -- skipmatch (a:Person) return a skip 1;
从结果看alicy被跳过去了
-- merge 语法 无则添加有则不动match(a:Person{name:"Tom"}),(b:Person{name:"LaoWang"}) merge (a)-[lv:love]->(b) return a, b ; -- 加上唯一约束
CREATE CONSTRAINT ON (n:Person) ASSERT n.name IS UNIQUE;
-- in 语句不能使用()而是[]
match(p:Person) where p.name in ["Tom","test"] return p;