Getting hierarchy data from self-referencing tables

前端 未结 5 1571
孤独总比滥情好
孤独总比滥情好 2020-12-13 15:00

Let\'s say you have the following table:

items(item_id, item_parent)  

... and it is a self-referencing table - item_parent r

5条回答
  •  生来不讨喜
    2020-12-13 15:41

    There is a good tech article on the mysql website about hierarchical data in MySql: Managing Hierarchical Data in MySQL - you can find a few detailed solutions with pro and cons there.

    Especially the part about "The Nested Set Model" and "Finding the Depth of the Nodes" should be of interest for you.

提交回复
热议问题