Teacher please help to see?
How to reorder the siblings in an infinite category
SELECT `DishCategory_Path`,`DishCategory_Name`,`DishCategory_Sort`,concat(`DishCategory_Path`,'-',id) as fullpath from chi_category order by fullpath asc,`DishCategory_Sort`asc
FullPath is sorted, but because order by requires that the second column be used only if the first column is the same when sorting by more than one column. But the first group of FullPath is unlikely to be the same. Now how to achieve such as red wine sub-category red wine 1 and red wine 2 of these two re-implementation sort.
Asking for advice.
Reply content:
Teacher please help to see?
How to reorder the siblings in an infinite category
SELECT `DishCategory_Path`,`DishCategory_Name`,`DishCategory_Sort`,concat(`DishCategory_Path`,'-',id) as fullpath from chi_category order by fullpath asc,`DishCategory_Sort`asc
FullPath is sorted, but because order by requires that the second column be used only if the first column is the same when sorting by more than one column. But the first group of FullPath is unlikely to be the same. Now how to achieve such as red wine sub-category red wine 1 and red wine 2 of these two re-implementation sort.
Asking for advice.
I took a closer look at the problem.
Now the first field is the parent ...
It takes only a single brain to get all the categories out, and then use the dynamic language to sort them out.
Old Answer:
Add a field father , red wine 1 and red wine 2 are father 0-12-16 , you can.
SELECT DishCategory_Path,DishCategory_Name,DishCategory_Sort, concat(DishCategory_Path,'-',id) as fullpath from chi_category order by concat(DishCategory_Path,'-',DishCategory_Sort)
The effect of this remark
In fact, I do not know that the problem is ultimately to solve the problem, what the demand is not clear.
If you want to sort output two-level classifications on a page, that's not what SQL does.