У меня есть следующая таблица в результате запроса:
SELECT f.id, f.parent_id, f.name, f.fullpath,
FROM folders f
WHERE fullpath LIKE CONCAT("%", 'fs-3', "%")
ORDER BY fullpath ASC, name ASC;
id parent_id name fullpath
-----------------------------------------------------------------
fs-3 null root fs-3
fs-d fs-3 test fs-3/fs-d
fs-5 fs-d test fs-3/fs-d/fs-5
fs-g fs-3 test3 fs-3/fs-g
fs-2 fs-g test fs-3/fs-g/fs-2
fs-s fs-2 test fs-3/fs-g/fs-2/fs-s
fs-y fs-3 test2 fs-3/fs-y
fs-4 fs-y test fs-3/fs-y/fs-4
Таблица отсортирована по
ORDER BY fullpath ASC, name ASC
Желаемый результат: name column
получает отсортировано таким образом, что test3
идет после test2
при сохранении сортировки fullpath
. Но я не знаю, как этого добиться?
id parent_id name fullpath
-----------------------------------------------------------------
fs-3 null root fs-3
fs-d fs-3 test fs-3/fs-d
fs-5 fs-d test fs-3/fs-d/fs-5
fs-y fs-3 test2 fs-3/fs-y
fs-4 fs-y test fs-3/fs-y/fs-4
fs-g fs-3 test3 fs-3/fs-g
fs-2 fs-g test fs-3/fs-g/fs-2
fs-s fs-2 test fs-3/fs-g/fs-2/fs-s