sql表结构中,存在IdParentId结构,查询指定父级的所有子级

it2022-05-05  151

主键:OrganizeId 父级Id:ParentId 查询父Id(db063c8c-3c4b-435b-82ca-c951f7302c3d)下所有子级记录

with cte as ( select * from Base_Organize where ParentId='db063c8c-3c4b-435b-82ca-c951f7302c3d' union all select a.* from Base_Organize a join cte b on a.ParentId=b.OrganizeId ) select * from cte

最新回复(0)