ITeye博客

SQL SERVER WTIH AS

CHEEN · 2013-05-03 16:20 · sqlServer · 数据库 · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。