递归

with temp ( [Id], [parentid])
as
(
select Id, parentid
from DiGui
where [parentid] = 15
union all
select a.Id, a.parentid
from DiGui a
inner join temp on a.[parentid] = temp.[Id]
)
select * from temp
posted @ 2017-07-25 15:54  wuyong360  阅读(103)  评论(0编辑  收藏  举报