sql 递归,父子类查询

with
temp
as
(
select *
from tablea
where ID =666
union all
select b.*
from temp
inner join tablea b on b.ID=temp.ID
)
select *
from temp

你可能感兴趣的:(sql,server,sql,数据库,database)