sql递归显示层级数据
2024-08-22 22:50:08
;with catChild as(select *,cast(right(''+cast(Sort as varchar),5) as varchar(max)) as ssort
from Category where ID = '123'
union all select t.*,
cast(ssort+right(''+cast(t.Sort as varchar),5) as varchar(max))
from catChild, Category t
where catChild.ID = t.ParentID)
select * from catChild where IsVolumes='' order by ssort,Sort ;with cte as
(select ID,Name,ParentID,1 level,
cast(right(''+cast(Sort as varchar),5) as varchar(max)) as ssort
from Category where ID = '111A'
union all select t.ID,t.Name,t.ParentID,c.level + 1,
cast(ssort+right(''+cast(t.Sort as varchar),5) as varchar(max))
from Category t
join cte c on t.ParentID = c.ID)
select ID, Name, ParentID, level,ssort
from cte order by ssort
最新文章
- CTO干点啥?
- 实战之中兴ZXHN F460光猫破解超级密码+开启无线路由功能
- ECMAScript —— 学习笔记(思维导图版)
- 基于SocketAsyncEventArgs的版本
- Linux Bash命令关于程序调试详解
- Benefits of Cold Showers: 7 Reasons Why Taking Cool Showers Is Good For Your Health
- 卷积神经网络 cnnff.m程序 中的前向传播算法 数据 分步解析
- android 简单的开机自启
- iOS开发 改变UINavigationController的UINavigationBar的高度和背景图片
- solrCloud设置Tomcat jvm内存解决内存溢出的问题
- JS的if和switch
- R画网络图
- python之做一个简易的翻译器(二)
- [原]Jenkins(二十一) jenkins再出发Build periodically和Poll SCM
- 学JS的心路历程Day28 - PixiJS -基础(二)
- tomcat+bean例子
- A-Softmax的总结及与L-Softmax的对比——SphereFace
- ASP.NET的内置对象 —— Request 对象
- SQLInjection 靶场配置
- Azure Nosql
热门文章
- web 给大家分享一个好玩的东西,也许你那块就用的到
- ASP.NET MVC学习目录
- WPF圆角按钮
- python中的基本数据类型(int,bool,str)及字符串操作
- Eclipse导出JAR过程
- 深浅copy和浅copy
- 2018-2019-2 网络对抗技术 20165219 Exp3 免杀原理与实践
- “全栈2019”Java多线程第十章:Thread.State线程状态详解
- Python(序列化json,pickle,shelve)
- jenkins+gitlab+robot framework 中遇到的坑