标签:
查找所有父结点:
WITH CTE_Area
AS ( SELECT *
FROM Common.Area
WHERE AreaCode = ‘30A‘
UNION ALL
SELECT b.*
FROM CTE_Area a,
Common.Area b
WHERE a.ParentCode = b.AreaCode
)
SELECT *
FROM CTE_Area;
查找所有子结点:
WITH CTE_Area
AS ( SELECT *
FROM Common.Area
WHERE AreaCode = ‘1‘
UNION ALL
SELECT b.*
FROM CTE_Area a,
Common.Area b
WHERE a.AreaCode = b.ParentCode
)
SELECT *
FROM CTE_Area;
标签:
原文地址:http://www.cnblogs.com/pgboy/p/5496742.html