基礎數據/表結構 Sql 語句 結果 ...
- 基礎數據/表結構
- Sql 語句
1 ;With cte(id,pid,TName)As 2 ( 3 Select id,pid,TName 4 From Test where pid = 1 5 Union All 6 Select B.id,B.pid,B.TName 7 From cte Inner Join Test B On cte.id = B.pid 8 ) 9 select * from cte order by id
- 結果
基礎數據/表結構 Sql 語句 結果 ...
1 ;With cte(id,pid,TName)As 2 ( 3 Select id,pid,TName 4 From Test where pid = 1 5 Union All 6 Select B.id,B.pid,B.TName 7 From cte Inner Join Test B On cte.id = B.pid 8 ) 9 select * from cte order by id