select * from UserInfo ;--所有数据
with cte
as
(
select * from UserInfo where UId='2'
union all
select B.*
from cte A ,UserInfo B where B.UFatherUserId = A.UId and A.UFatherUserId <>B.UId
)
select * from cte--uid为2的数据及子数据
select * from UserInfo ;--所有数据
with cte
as
(
select * from UserInfo where UId='2'
union all
select B.*
from cte A ,UserInfo B where B.UFatherUserId = A.UId and A.UFatherUserId <>B.UId
)
select * from cte--uid为2的数据及子数据