--由父项递归下级 with cte(refid,pid,zname,code) as (--父项 select refid,pid,zname,code from zuzhi where pid = 38 union all --递归结果集中的下级 select t.refid,t.pid,t.zname,t.code from zuzhi as t inner join cte as c on t.pid = c.refid ) select refid,pid,zname,code from cte
时间: 2024-10-24 20:27:15