用CTE递归
;
with
f
as
(
select
*
from
tab
where
id=1
union
all
select
a.*
from
tab
as
a
inner
join
f
as
b
on
a.pid=b.id
)
select
*
from
f
时间: 2024-10-12 16:58:49
用CTE递归
;
with
f
as
(
select
*
from
tab
where
id=1
union
all
select
a.*
from
tab
as
a
inner
join
f
as
b
on
a.pid=b.id
)
select
*
from
f