stublackett Posted August 15, 2008 Share Posted August 15, 2008 Hi, I've got a DB Table which has a "Month" column What I'm looking to do is order it by Month DESC I'm achieving this, But the numbers that are coming through are ordered like this : 9 9 8 8 7 7 11 Yet when I order the eventid DESC it orders it properly, Any ideas how I can sort this out? So that its ordered by month Table layout is as follows..... id title location hour minutes day month Link to comment https://forums.phpfreaks.com/topic/119810-solved-order-by-desc-asc/ Share on other sites More sharing options...
adam84 Posted August 15, 2008 Share Posted August 15, 2008 SELECT * From db_table ORDER BY month desc Link to comment https://forums.phpfreaks.com/topic/119810-solved-order-by-desc-asc/#findComment-617320 Share on other sites More sharing options...
stublackett Posted August 15, 2008 Author Share Posted August 15, 2008 SELECT * From db_table ORDER BY month desc I've done that..... Those months are not being ordered properly ??? My code is : <?php $result = mysql_query("SELECT * FROM $db_table ORDER BY month DESC LIMIT 5 "); ?> Link to comment https://forums.phpfreaks.com/topic/119810-solved-order-by-desc-asc/#findComment-617325 Share on other sites More sharing options...
akitchin Posted August 15, 2008 Share Posted August 15, 2008 what type of field is month? that's likely what is messing up the ORDER BY clause. Link to comment https://forums.phpfreaks.com/topic/119810-solved-order-by-desc-asc/#findComment-617384 Share on other sites More sharing options...
stublackett Posted August 15, 2008 Author Share Posted August 15, 2008 what type of field is month? that's likely what is messing up the ORDER BY clause. That was it, Cheers akitchin for some stupid reason I set the month field to VARCHAR, now changed to INT and its gone straight through.... Cheers *SOLVED* Link to comment https://forums.phpfreaks.com/topic/119810-solved-order-by-desc-asc/#findComment-617392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.