[thelist] mysql: monthname results order
rudy
r937 at interlog.com
Fri Mar 14 16:54:18 CST 2003
hi dunstan
i replied to this earlier today, but it was via webmail on a
cybercafe computer, and i guess it didn't go through
> SELECT DISTINCT MONTHNAME(date) AS month
> FROM date
> WHERE (date <> '0000-00-00')
> ORDER BY month ASC
>
> At the moment that returns the months in alphabetical order...
> how can I return them in the correct calender order?
here are the suggestions i tried to make:
do not give the same name to both a table and one of its columns
do not use a reserved word (date) as the name of a table or column
do not use a "zero date" -- use a null instead
with these suggestions in mind, try this --
select distinct
monthname(thedate) as alphamonth
, month(thedate) as numericmonth
from thetable
where thedate is not null
order
by month(thedate) asc
rudy
More information about the thelist
mailing list