![]() |
Mysql ORDER BY Help needed
I need to know how to order mysql queries so that they are first ordered by Rating, then when Rating = 1, order by Hits_Sent.
Is that at all possible? |
select * from table where rating = "1" order by Hits_Sent
Why would you want to order by rating first, if you are only going to return where rating equals 1? Maybe you need to explain more on what you are looking to do. |
ICQ me if you want to.
|
Rating can be anywhere from 1 to 10.
For every result that has a Rating over 1, I want them to be ordered by Rating. The rest are Rating='1' and they have to be ordered by Hits_Sent. |
Quote:
Or start at 2 and work up to 10...and then return rating = 1? |
He wants the equivelent of this:
Select info and order it by rating first 10 to 1 and then if those have matches, order it by hits sent higher before lower. So rating 6 hits sent 10 comes before rating 6 hits send 5. |
Have you tried
SELECT * FROM table GROUP BY rating ASC ORDER BY Hits_Sent DESC |
SELECT * FROM TABLE
ORDER Ratings DESC, Hits_Sent This will first order it by Ratings Descending 10 to 1 and then within those ratings it will order it by Hits_Sent |
select rating, if(rating=1,hits_sent,0) as hits_sent from table order by rating asc, hits_sent desc
|
I dont mind helping out with a random question here and there, but perhaps you would be better off asking programming and database questions at a different forum.
They are, after all, non-porn-specific and you might get more help there. Just a suggestion. :helpme |
| All times are GMT -7. The time now is 03:54 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123