MySQL custom function Implementation of recursive hierarchy in the table display

Source: Internet
Author: User

1. Now take the menu table as an example to create a table Test_menu in the database.

2. Create some instance data in the table

Now the menu level for Cd_1 and Cd_2 for a first-level menu, Cd_1 is divided into cd_1_1 and cd_1_2 two level two menu, Cd_1_1 has a three-level menu cd_1_1_1, directory structure as follows

Cd_1

Cd_1_1

Cd_1_1_1

Cd_1_2

Cd_2

3. Create a Custom function

4. Query Menu Hierarchy


Here, the menu is clearly displayed at all levels.

MySQL custom function Implementation of recursive hierarchy in the table display

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.