欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SQLserver2008使用表達式遞歸查詢

 更新時間:2010年05月07日 22:57:25   作者:  
SQLserver2008使用表達式遞歸查詢語句,需要的朋友可以參考下。
復(fù)制代碼 代碼如下:

--由父項遞歸下級
with cte(id,parentid,text)
as
(--父項
select id,parentid,text from treeview where parentid = 450
union all
--遞歸結(jié)果集中的下級
select t.id,t.parentid,t.text from treeview as t
inner join cte as c on t.parentid = c.id
)
select id,parentid,text from cte

---------------------

--由子級遞歸父項
with cte(id,parentid,text)
as
(--下級父項
select id,parentid,text from treeview where id = 450
union all
--遞歸結(jié)果集中的父項
select t.id,t.parentid,t.text from treeview as t
inner join cte as c on t.id = c.parentid
)
select id,parentid,text from cte

相關(guān)文章

最新評論