with as递归调用

一、递归调用--在代码中偶尔看到以记之,便于下次学习

https://blog.csdn.net/johnf_nash/article/details/78681060

--查询节点及其下所有子节点
WITH T AS 
    ( SELECT id as ids,ModuleName,ParentId,IconPath,JspPath FROM T_Sys_MenuModule WHERE ParentId = '0' and  isshow =1 UNION ALL SELECT a.id,
    a.ModuleName,a.ParentId,a.IconPath,a.JspPath FROM T_Sys_MenuModule a INNER JOIN T ON a.ParentId = T.ids  where  isshow =1) 
 SELECT * FROM T left join T_Sys_RoleAuthority a on a.moduleid = T.ids where   roleid='109' or  1=0 order by T.ids asc;

 

posted @ 2018-08-14 20:12  达摩院的BLOG  阅读(199)  评论(0编辑  收藏  举报