How to get last results out of my DB in order
Posted 07 March 2006 - 01:24 PM
This is my case. I have an mysql db in which names are stored. Some of them have a rating, some don't. Now i want to make a top 10 based on this rating. But i also want to show the 10 last ones. (i exclude the ones without a rating from the top10).
Now this is where i'm stuck because i also want to have the 10 last ones in a descending order. (So ORDER BY rating DESC LIMIT 10) won't do. I'll have to resort the result i get from this.
Anyone any ideas?
Posted 12 March 2006 - 05:40 PM
NOBODY of you can solve this one?
Seems i'm only helping others these days...
Posted 12 March 2006 - 06:23 PM
SELECT * FROM table WHERE rating > '' ORDER BY rating DESC
Posted 12 March 2006 - 07:30 PM
(SELECT * FROM table ORDER BY rating DESC LIMIT 10) ORDER BY rating
I think that works but I can't remember trying it. If it doesn't, you can just make it a real subquery and put it in the FROM:
SELECT f.* FROM (SELECT * FROM table ORDER BY rating DESC LIMIT 10) f ORDER BY f.rating
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users