I have a "category" table like this:
+------+---------++---------+
| id | parent || weight |
+------+---------++---------+
| 1 | 0 || 0 |
| 2 | 1 || -1 |
| 3 | 1 || -2 |
| 4 | 2 || 0 |
| 5 | 1 || 1 |
| 6 | 5 || 0 |
| 7 | 5 || 1 |
+------+---------++---------+
How can I ORDER BY
and SELECT
statement to get the order like this:
1 5 7 6 2 4 3
in the first level every category in main branch (parent=1) get the order by their weights, while they have their children behinds. thank You and sorry for my eng