-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Actually, it's not working quite as perfect as I thought. When using ASC, it works fine, but when using DESC for sort order, it's quirky.
For example, in ASC mode, it orders like this: Sep 28, 2003 Oct 05, 2003 Dec 06, 2003 Dec 31, 2003 Jan 02, 2004 Jan 10, 2004 Jan 14, 2004
That's perfect, but in DESC mode, it orders like this: Sep 28, 2003 Oct 05, 2003 Dec 31, 2003 Dec 06, 2003 Jan 14, 2004 Jan 10, 2004 Jan 02, 2004
It just orders the dates descending within their respective months, but it doesn't order DESC by year or month. I figured out how to fix it, though. I just placed DESC after each item listed in the ORDER BY.
But that's how sorting works. Otherwise, how would you sort some columns in one order, and some in the opposite order?
By the way, why do you have MID(datecol,8) rather than MID(datecol,9)?
Ben Ramsey wrote: | Works perfectly! Thanks! | | Roger Baklund wrote: | | Yes, it can be done using the FIELD() function: | | | | SELECT * FROM tablename | | ORDER BY | | MID(datecol,8), # year | | FIELD(LEFT(datecol,3), # month | | 'Jan','Feb','Mar','Apr','May','Jun', | | 'Jul','Aug','Sep','Oct','Nov','Dec'), | | MID(datecol,5,2); # day | | | | <URL: http://www.mysql.com/doc/en/String_functions.html#IDX1185 >
-- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com
MySQL Users Conference: April 14-16, 2004 http://www.mysql.com/uc2004/
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]