Thomas Bartkus wrote:
"Nick Weisser" <ni**@nospam.freemails.chwrote in message
news:44**********@news.bluewin.ch...
Hi there,
I'm not sure how to select the last 3 items in ascending order.
This does the trick in descending order:
select * from user_menu_main
where deleted = 0 and hidden = 0
order by date desc
limit 3
Your comments would be very much appreciated.
That problem is a natural for a temporary table.
create temporary table tmp
select * from user_menu_main
where deleted = 0 and hidden = 0
order by date desc
limit 3;
select * from tmp
order by date desc;
Thomas Bartkus
I see, you want to limit your select to last three items of a list, but
have those items listed in the ordinary order. Well Thomas's solution
is probably the most straightfoward, although (depending on your
version) you don't actually need to create the temporary table:
(untested)
select * from (
select * from user_menu_main
where deleted = 0 and hidden = 0
order by date desc
limit 3) tmp
order by date asc;