[thelist] Q on SQL 'ORDER BY' - part 2

Maximillian Schwanekamp anaxamaxan at neptunewebworks.com
Mon Apr 12 00:59:38 CDT 2004


A good solution has already been offered on this one, but a comment: the
reason for the result set ordering Walter initially got was because Null
comes before anything else alphabetically in MySQL.
> ORDER BY contacts.con_title, contacts.con_name;
So with this order by, the order is understandable:
Patrick Ryan, NULL
Scott Shannon, NULL
Lisa Jackson, Creative Services Manager
NULL, Director of Marketing and Promotions
NULL, Director of Sales
Chris Ingram, Director, News and Programming

The first two rows come first because they have NULL for con_title, and are
sorted by con_name.  The last three rows are correct because "Creative"
comes before "Director" in the con_title order, and "Director, " comes after
"Director ".

If I am off-base here, please someone correct me.

Maximillian Von Schwanekamp
NeptuneWebworks.com
voice: 541-302-1438
fax: 208-730-6504




More information about the thelist mailing list