sql 树 递归
with SubQuery(No,Name,ParentNo) as (
select No,[Name],ParentNo from [Port_Dept] where No = ''
union all
select A.No,A.Name,A.ParentNo
from [Port_Dept] A inner join SubQuery B
on A.No = B.ParentNo
)
select * from SubQuery
sql 树 递归
with SubQuery(No,Name,ParentNo) as (
select No,[Name],ParentNo from [Port_Dept] where No = ''
union all
select A.No,A.Name,A.ParentNo
from [Port_Dept] A inner join SubQuery B
on A.No = B.ParentNo
)
select * from SubQuery