Reputation: 11448
I have a mysql query:
SELECT `name` FROM `table1` WHERE id='0' ORDER BY `id` DESC LIMIT 5
This is ok, it gets me the last 5 elements with the very last in the table being the first in the returned array. ok.
But! I am trying to get the last 5 in normal table order (so the last in the main table would be number 5 in the returned array and the one before that would be 4 etc.)
I tried ASC, it didn't work...
How can I do this?
Upvotes: 0
Views: 3834
Reputation: 1
For simplicity: use the dot I.e table1.name, e.g.
$query = "SELECT * FROM `users` ORDER BY `users`.`date_of_rsvp` DESC";
I think this should work.
Upvotes: 0
Reputation: 4612
Try this
select `name`
from (
select `id`, `name`
from `table1`
where id='0'
order by `id` desc
limit 5
) as source
order by `id` asc
Upvotes: 3