How to implement MySql multi-level menu query
Article Introduction:In background work (especially in traditional projects), we often encounter this kind of need, which is tree structure query (multi-level query). Common scenarios include: organizational structure (user department) query and multi-level menu query. For example, menu classification It is three levels, first-level menu, second-level menu, and third-level menu. The user is required to query the menus at each level according to the tree structure. As shown in the figure below, for fixed levels and a small number of levels, usually 3 levels, the requirements are very simple to implement. First query the smallest child level, then query the upper levels in sequence, and finally assemble it and return it to the front end. Then the question comes, if the number of levels is very large, 10 levels, or simply the levels are uncertain, some are 3 levels, some are 5 levels, some are 8 levels, compared with the previous fixed levels and number of levels, the problem is obviously more complicated. Okay, let’s see how to deal with this
2023-05-27
comment 0
1531