sql server 获取指定节点的所有父节点或者所有子节点
sql 获取指定节点的所有父节点或者所有子节点获取节点的所有父节点
;with
#tmp as(
select * from tb
whereid ='DMA20120327036'
union all
select a.* from tb a, #tmp b
where a.id = b.pid
)
select * from #tmp
获取节点的所有子节点
;with
#tmp as(
select * from tb
whereid ='DMA20120327036'
union all
select a.* from tb a, #tmp b
where a.pid = b.id
)
select * from #tmp
页:
[1]