I'm a beginner in the world of databases but I did have enough sense to consult the MySql Manual before asking this simple question. No help there.
Here's my problem: I am trying to sort a column that contains the days of a month. When I sort the column (order by day asc) it puts a day of (for example) 2 AFTER a day like 19.
Here's my question: Is there any way that I can query the database and let it know that even though there is no leading zero before the 2, it is still lower than 19?
Thanx.
[SOLVED] ORDER by ASC not working!
Moderator: General Moderators
If you're ordering by months and they're text, you can do this:
Code: Select all
$sql = mysql_query("select * from my_table order by ".
"month='January' ASC, " .
"month='February' ASC, " .
"month='March' ASC, " .
"month='April' ASC, " .
"month='May' ASC, " .
"month='June' ASC, " .
"month='July' ASC, " .
"month='August' ASC, " .
"month='September' ASC, " .
"month='October' ASC, " .
"month='November' ASC, " .
"month='December' ASC") or die ("Query failed.");
mysql_query($sql);