数据库 - 多级分类如何遍历
某草草
某草草 2017-04-24 16:00:58
0
2
887

现有一张表
表结构
Id,name,description,parent_id
一个分类下有多个子分类,每个子分类下又会有子分类,深度多达10层左右。
分类的排列也是不规则的,现在希望获得的结果如下:
水果

  • 国产水果

    • 北方地区

      • 辽宁
      • 山东
        ....
    • 南方地区

      • 湖南
        ....
  • 进口水果
    ....
  • 精品礼盒
    ....

...

某草草
某草草

reply all(2)
伊谢尔伦

It is best not to use recursive methods for this kind of infinite classification

There is a relatively efficient solution (lvalue-rvalue solution) for classification information that changes little in the tree itself:
http://ftp.nchu.edu.tw/MySQL/tech-resources/articles/hierarchical- data.html

淡淡烟草味

@Huijiewei is right. The conventional method is lvalue and rvalue. This is relatively easy to use. http://www.arkulo.com/2015/02/25/Hierarchical/ This is the Chinese article about this method. An article by , I hope it will be helpful to you~~

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template