/**PageBeginHtml Block Begin **/ /***自定义返回顶部小火箭***/ /*生成博客目录的JS 开始*/ /*生成博客目录的JS 结束*/

mysql 树形查询 结果


image

 with recursive t1(id, parent_id) as (
select*from blog_temp.etc_test t0 where t0.parent_id is null  -- Anchor member.
 union all
select t2.id, t2.parent_id from blog_temp.etc_test t2, t1  -- Recursive member.
 where t2.parent_id = t1.id
)
select  lpad(codename,(length(codename)+v.dict_level*4),' ')  codename1 ,lpad(id,(length(id)+v.dict_level*4),' ')  id1   , v.*
from tree_dict v ;

image

posted @ 2022-09-14 11:07  一品堂.技术学习笔记  阅读(72)  评论(0编辑  收藏  举报