tab1 表结构: create tab1 ( id int primary key identity(1,1), parentid int not null, name varchar(25) ) 递归语法(利用CTE表达式): 1.根据父id递归查询子id with tem1(id,parentid,name) as( select id,parentid,name from tab1 where id = 1 union all select tab1.id,tab1.parentid,t…