当前位置:网站首页>Recursive data query of tree structure in a table in SQL Server
Recursive data query of tree structure in a table in SQL Server
2022-04-22 19:23:00 【Pingshan CP3】
demand : A data table is a tree structure , namely id,pid, Each record will have its own parent record . Now let's take the specified record and the record as the parent , Query all subordinate level records .
solve : It's used in this sqlserver Of with as Statements and union all Merge
WITH Emp
AS ( SELECT * FROM dbo.Users WHERE ID = '111'
UNION ALL
SELECT d.* FROM Emp INNER JOIN dbo.Users d ON d.pid= Emp.ID
) SELECT * FROM Emp
版权声明
本文为[Pingshan CP3]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221922242412.html
边栏推荐
猜你喜欢

项目实训- 基于unity的2D多人乱斗闯关游戏设计与开发(五、利用AudioMixer控制音量大小)

transfer方法详解

if-else 优化

14 sprak set automatic zoning

完美转发实现机制

mmocr DBLoss

The 14th issue of HMS core discovery reviews the long article | enjoy the silky clip and release the creativity of the video

08-UDFs

值得推荐的chrome插件

项目实训- 基于unity的2D多人乱斗闯关游戏设计与开发(小地图修改完善)
随机推荐
MySQL index
关于字符串常量池,intern方法的理解
VS 2022 安装vld内存泄漏检测工具
linux系统下redis相关问题
深开鸿与亿晟科技签署合作协议,携手构建商显行业新生态
13-Set Time Zone
时间日期格式化
Revit (5) - 二开 -创建墙体
工商银行分布式服务C10K场景的解决方案
13-Set Time Zone
Garbage collector and CMS G1
【Appium踩坑】Could not proxy command to the remote server. Original error: timeout of 240000ms exceeded
CMS垃圾收集器和G1垃圾收集器
mysql 学习笔记
Webrtc: mesh / MCU / SFU three communication architectures
Detailed network structure diagram of dbnet character detection
mmocr DBLoss
sqlserver可用空间过大,回收未用空间
Fingerprint identification record
阿里云安装 ffmpeg