摘要: --查找当前用户所在部门的所有下级包括当前部门 with cte as ( select Id,Pid,DeptName, 0 as lvl from Department where Id = 2 union all select d.Id,d.Pid,d.DeptName,lvl + 1 from cte c inner join Department d ... 阅读全文
posted @ 2019-11-22 16:37 博客燕 阅读(2279) 评论(0) 推荐(0)
摘要: 原网址:https://www.cnblogs.com/guofeiji/p/5291486.html 如果表中包含层级数据,可以使用层级查询子句按层级顺序选择数据行,形成层级树,形式如下: 下面是层级查询字句的火车图: START WITH:指定层级的根行。即根据条件选取一些行,以这些行做最顶级行 阅读全文
posted @ 2019-11-22 15:21 博客燕 阅读(1419) 评论(0) 推荐(0)