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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SFADuncan
Forum Newbie
Posts: 23
Joined: Mon Aug 11, 2003 5:06 pm
Location: uk

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

Post 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
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

SFADuncan
Forum Newbie
Posts: 23
Joined: Mon Aug 11, 2003 5:06 pm
Location: uk

Group By

Post 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
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post 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:
Post Reply