SQL查询递归

WITH DEPARTMENT AS
(
--定位点成员定义
SELECT *,0 AS LEVEL
FROM PE_FC_FileCategory WHERE CategoryID=3 --【当前部门ID
UNION ALL
--递归成员定义
SELECT E.*,Level+1
FROM PE_FC_FileCategory AS E
INNER JOIN DEPARTMENT AS D ON E.ParentID=D.CategoryID
)
SELECT * from DEPARTMENT OPTION(maxrecursion 100)
上一篇:风云的银光志Silverlight4.0教程之轻松操作剪切板


下一篇:Spring AOP 实现原理