日期:2014-05-17 浏览次数:20571 次
--> 测试数据: @T declare @T table (fid int,pid int) insert into @T select 1,0 union all select 2,0 union all select 3,1 union all select 4,3 union all select 5,4 union all select 6,0 --得到某节点的所有父节点 ;with maco as ( select * from @T where fid=4 union all select a.* from @T a ,maco b where a.fid=b.pid ) select * from maco order by fid /* fid pid ----------- ----------- 1 0 3 1 4 3 */
------解决方案--------------------
这头像是小齐嘛?要是是的话,难得啊!