`
CHEEN
  • 浏览: 134525 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

SQL SERVER WTIH AS

阅读更多
with result  
as
(
 select id, parentid,name from syst_dept where id = 'b649a10a3fa8017b003165fea703fa81'
 union all
 select a.id,a.parentid,a.name from syst_dept a join result b on
                                                      -- b.parentid = a.id  -- 向上查询
                                                      a.parentid = b.id  --向下查询
)
select * from result
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics