3 ms·
How do you make a SELECT that gets the items in the correct order? The point of the solution here is so you can simply go `SELECT * FROM list ORDER BY pos` and
by cthor 9y ago
How do you make a SELECT that gets the items in the correct order?
The point of the solution here is so you can simply go `SELECT * FROM list ORDER BY pos` and have the correct order.
- schrodinger 9y agoYou don't. You order it on the client!
- dzamo_norton 9y agowith recursive todo_list_sorted as ( select * from todo_list tl1 where prev_id is null union all select tl1.* from todo_list tl1 join todo_list_sorted tl2 on tl1.prev_id = tl2.id ) select * from todo_list_sorted