查找所有父结点:
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;
时间: 2024-09-30 02:01:43