sqlserver 递归查询的一种写法

  with tmp as
 (
 select a.id,a.name,a.pid from tb a where id='003'
 union all 
 select k.id,k.name,k.pid  from tb k inner join tmp c on c.id = k.pid

 )select * from tmp

posted on 2014-10-08 08:30  中子持心  阅读(246)  评论(0)    收藏  举报

导航