Neo4j常见语法-unwind

unwind的用法(UNWIND 是一个强大的操作符,用于将集合(列表、数组)展开为多行数据。它类似于关系型数据库中的 UNNEST 或 LATERAL JOIN,是 Cypher 查询中处理集合数据的核心工具)

(1)基本语法

bash 复制代码
UNWIND <collection> AS <variable>

核心功能:

bash 复制代码
将集合(如列表、数组)展开为多行,每行包含集合中的一个元素。
常见场景:
批量数据处理
集合元素与图节点关联
复杂数据结构扁平化

(2)展开简单列表

bash 复制代码
WITH [1, 2, 3, 4] AS numbers
UNWIND numbers AS num
RETURN num  // 返回四行:1, 2, 3, 4

(3)结合 Merge 创建关系

bash 复制代码
Merge (m:Movie {title: "流浪地球2"})
WITH m, ["吴京", "李雪健", "沙溢"] AS actors

UNWIND actors AS actorName
MERGE (a:Actor {name: actorName})
MERGE (a)-[:ACTED_IN]->(m)
相关推荐
serve the people17 小时前
tensorflow 零基础吃透:TensorFlow 稀疏张量(SparseTensor)的核心用法
人工智能·tensorflow·neo4j
serve the people17 小时前
tensorflow 零基础吃透:RaggedTensor 的不规则形状与广播机制
人工智能·tensorflow·neo4j
serve the people17 小时前
tensorflow 零基础吃透:RaggedTensor 的底层编码原理
人工智能·tensorflow·neo4j
MasonYyp2 天前
简单使用FalkorDB和Neo4j图数据库
数据库·neo4j
黑客思维者3 天前
XGW-9000系列高端新能源电站边缘网关技术可行性分析报告V2
neo4j
serve the people3 天前
tensorflow 零基础吃透:RaggedTensor 的索引与切片(规则 + 示例 + 限制)
人工智能·tensorflow·neo4j
serve the people3 天前
tensorflow 零基础吃透:RaggedTensor 与其他张量类型的转换
人工智能·tensorflow·neo4j
serve the people3 天前
tensorflow 零基础吃透:tf.function 与 RaggedTensor 的结合使用
人工智能·tensorflow·neo4j
serve the people3 天前
tensorflow 零基础吃透:SavedModel 与 RaggedTensor 的结合使用
人工智能·tensorflow·neo4j
serve the people4 天前
tensorflow 零基础吃透:RaggedTensor 的重载运算符
人工智能·tensorflow·neo4j