日期:2014-05-18 浏览次数:20577 次
--上一级 declare @id int set @id = 9 select * from tb where AreaId = (select top 1 UpperId from tb where AreaId = @id) --所有上级 ;with cte as ( select * from tb where AreaId = @id union all select a.* from tb a join cte b on a.AreaId = b.UpperId ) select * from cte