在Neo4j中,Cypher是一种用于查询和操作图数据库的语言
MATCH (a:Person)
RETURN a
UNION
MATCH (b:Person)
RETURN b
MATCH (a:Person {name: "Alice"})-[:KNOWS]->(b:Person)
RETURN a, b
MATCH (a:Person {name: "Alice"})-[:KNOWS]->(b:Person)
WITH a, b
MATCH (c:Person)-[:KNOWS]->(d:Person)
WHERE d IN (a, b)
RETURN c, d
MATCH (a:Person)
WHERE (
SIZE([(a)<-[:KNOWS]-(b:Person) | b]) > 2
)
RETURN a
MATCH (a:Person)
MATCH (b:Person)
RETURN a, b
MATCH (a:Person)-[:KNOWS]->(b:Person)
RETURN a, b
SKIP 10
LIMIT 5
MATCH (a:Person)-[:KNOWS]->(b:Person)
RETURN a, b
ORDER BY b.age DESC
MATCH (a:Person)-[:KNOWS]->(b:Person)
WITH a, COUNT(b) AS num_friends
RETURN a, num_friends
ORDER BY num_friends DESC
MATCH (a:Person)-[:KNOWS]->(b:Person)
WITH a, COUNT(b) AS num_friends
RETURN a, AVG(num_friends) AS avg_friends
这些示例展示了如何在Cypher中使用集合操作。您可以根据需要组合和调整这些操作以满足您的查询需求。