Toni_montana Posted March 7, 2006 Share Posted March 7, 2006 Hey there,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?Rogier Quote Link to comment Share on other sites More sharing options...
Toni_montana Posted March 12, 2006 Author Share Posted March 12, 2006 Guys,NOBODY of you can solve this one?Seems i'm only helping others these days... Quote Link to comment Share on other sites More sharing options...
wisewood Posted March 12, 2006 Share Posted March 12, 2006 TOP 10...SELECT * FROM table WHERE rating > '' ORDER BY rating DESC Quote Link to comment Share on other sites More sharing options...
wickning1 Posted March 12, 2006 Share Posted March 12, 2006 If your MySQL is 4.1 or greater you should be able to add another ORDER BY, basically a subquery:[code](SELECT * FROM table ORDER BY rating DESC LIMIT 10) ORDER BY rating[/code]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:[code]SELECT f.* FROM (SELECT * FROM table ORDER BY rating DESC LIMIT 10) f ORDER BY f.rating[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.