如何对一个id,name,parentId进行树状化
来源:2-5 数据操作语言:排序
机电渣渣
2021-03-06 11:50:52
如何对一个id,name,parentId进行树状化
1回答
同学你好,同学可使用递归 CTE进行实现。如下图所示:
with recursive cte as
(select * from temp where id=1
union all
select a.* from temp a join cte b on a.parentId=b.id
)
select * from cte
祝学习愉快!
相似问题
回答 1
回答 1