用CTE递归
;with as 
(
select from tab where id=1
union all
select a.* from tab as inner join as on a.pid=b.id
)
select from f

相关文章: