Page 1 of 1

ORDER BY 5s, then 3s, then 4s

Posted: Tue Nov 29, 2005 7:41 am
by SFADuncan
I have the following query which works fine.

Code: Select all

$query = "select * from data_published where data_published.page_id = '$page_id' order by feature_order asc, data_published.time desc, data_published.feature_id asc LIMIT 27";
However, I also want to order it by another column, item_type_id. This column (INT) contains integers between 1 and 5. I wish to run the query as above, then subsequently order by item_type_id with 5s first, then 3s, then 4s.

Any ideas or assistance? I'd be very grateful.

Simon

Posted: Tue Nov 29, 2005 8:14 am
by Grim...

Group By

Posted: Tue Nov 29, 2005 9:07 am
by SFADuncan
ah... thanks... that could be it.... I've seen that used around the place... never actually used it myself.... not sure how to use it, but will check the manuals.... thanks!

Simon

Posted: Tue Nov 29, 2005 9:14 am
by foobar
Tip 598: Always check the MySQL Manual if you don't know something that specific. It ususally has your answer right there. :wink: