Non-recursive unlimited classification. For more information, see

Source: Internet
Author: User
Non-recursive unlimited classification. For more information, see section 2012-09-0510: 19: 59, cid is the column ID, category is the column name, chain is the relationship tree, rank is the column sorting mysql & gt; non-recursive unlimited classification, problem, please give pointers
At the end of this post, vbker edited the following database fields at 10:19:59 on. Currently, it uses region as the column, cid as the column ID, category as the column name, chain as the relationship tree, and rank as the column order.

Mysql> select * from mc_category;
+ ----- + ---------- + -------------- + ------ +
| Cid | category | chain | rank |
+ ----- + ---------- + -------------- + ------ +
| 1 | domestic | 0_1 | 2 |
| 2 | outside China | 0_2 | 1 |
| 3 | North China | 0_1_3 | 2 |
| 4 | northeast China | 0_1_4 | 1 |
| 5 | West | 0_00005 | 3 |
| 6 | Henan | 0_1_3_6 | 1 |
| 7 | Zhengzhou | 0_1_3_6_7 | 2 |
| 8 | | 0_1_3_6_7_8 | 1 |
| 9 | Luoyang | 0_1_3_6_9 | 1 |
| 10 | Yanshi | 0_1_3_6_9_10 | 1 |
| 11 | Liaoning | 0_1_4 | 3 |
| 12 | Jilin | 0_20174_11_12 | 1 |
| 13 | Shangjie | 0_1_3_6_7_13 | 2 |
+ ----- + ---------- + -------------- + ------ +


Use
select category,chain from mc_category group by chain order by chain;

The directory tree can be listed according to the correct parent-child relationship, but now I still need to sort the columns at the same level by rank value. can this be done using mysql?




========================================================== ============================== Share :? Select? *? From? Mc_cate... 'data-pics = ''>

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.