Answer the question
In order to leave comments, you need to log in
How to sort query by fields left_id, right_id?
In the database of my CMS, the fields ID, left_id, right_id are often found.
How can you sort by such records?
for example table
//Массив(таблица) для добавления записей в базу MYSQL, где порядок полей ['id', 'left_id', 'right_id']
$insert[3] = [3, 0, 7];
$insert[5] = [5, 7, 7];
$insert[7] = [7, 3, 5];
$insert[9] = [9, 5, 5];
Answer the question
In order to leave comments, you need to log in
Try to express the rule for your sorting in Russian first. Standard sorting by two fields sounds like "sort in ascending order of the first field, additionally sort rows with the same value in the first field in ascending order of the second field". What exactly do you want to get?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question