递归语句
WITH tempTable(ID) AS (
SELECT ID
FROM sys_menu
WHERE ID = '05161001' AND DEL_STATUS = 1
UNION ALL
SELECT m.ID
FROM sys_menu m
JOIN tempTable ON m.PARENT_ID = tempTable.ID AND DEL_STATUS = 1
)
SELECT *
FROM tempTable;
比如菜单树,拿到某个菜单,要查询它下面所有的子菜单,
通过这个语句,就可以拿到所有子菜单的 id,
有了 id , 再把这个 id 当筛选条件查询数据,就啥都有了。。。
标签:菜单,递归,tempTable,树结构,查询,id,ID,SELECT From: https://www.cnblogs.com/aaacarrot/p/17280986.html