I'm having problems with 3 queries.
First a normal select sorted by date:
select id
from app_order o
order by o.date
; // 30558, 30559, 30560, ...
Then one that should bring me the last record of the previous query:
select id
from app_order o
order by o.date
limit 1
; // 30558
And here a problem, if I get the last 3, completely change the order of the result:
select id
from app_order o
order by o.date
limit 3
; // 30559, 30560, 30558 -- aqui já muda completamente do primeiro
I solved the problem by adding the id to the order by, so there is a way to create an order in the results
order by o.date, o.id