e.g.
> Fruits (catNo = 010000)(nSort = 5)
>> Sweet (011000)
>>> Apple (011010)
>>> Pear (011020)
>> sour (012000)
>>> lemon (012010)
>>> lime
> Vegetables(020000)(nSort = 1)
>> Green
>>> Cucumber
>>> Lettuce
>> Red
>>> Paprika
>>> Radish
The list can be sorted by catNo or nSort.
Problem: I want to reorder this list so that Vegetables appears above fruits.
So, I want to sort it by nSort, but also maintain the 3level structure. Currently if I sort it only by nSort the list structure goes crazy. So I need to sort it by nSort and also by catNo somehow.
You can see the relationship of catNo to the structure (XXxxxx = 1st level or not, xxXXxx = 2nd level or not etc).
I think the answer is to do with using:
Code: Select all
SELECT * FROM table WHERE catNo IN(select * from table order by catNo) ORDER BY nSortOr, I can just get the list and order by catNo, then sort it using PHP with
Code: Select all
asort