国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > SQL Server > 正文

SQLserver2008使用表達(dá)式遞歸查詢(xún)

2024-08-31 01:00:50
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:


--由父項(xiàng)遞歸下級(jí)
with cte(id,parentid,text)
as
(--父項(xiàng)
select id,parentid,text from treeview where parentid = 450
union all
--遞歸結(jié)果集中的下級(jí)
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

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

--由子級(jí)遞歸父項(xiàng)
with cte(id,parentid,text)
as
(--下級(jí)父項(xiàng)
select id,parentid,text from treeview where id = 450
union all
--遞歸結(jié)果集中的父項(xiàng)
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

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 手游| 兴山县| 马尔康县| 牡丹江市| 白水县| 客服| 呈贡县| 公主岭市| 新余市| 油尖旺区| 通河县| 格尔木市| 陇西县| 旅游| 湖州市| 太湖县| 西峡县| 惠州市| 沅陵县| 历史| 延川县| 平度市| 长宁县| 宣城市| 和林格尔县| 宜城市| 邛崃市| 嘉黎县| 原平市| 闻喜县| 开鲁县| 新干县| 通城县| 玉树县| 渝中区| 梧州市| 安西县| 株洲市| 岚皋县| 修文县| 乌鲁木齐市|