At 6:27 PM -0700 9/14/03, Scott Haneda wrote:
on 09/14/2003 06:14 PM, Paul DuBois at [EMAIL PROTECTED] wrote:

 You can force NULL values to be sorted to either end by adding another
 sort column:

ORDER BY IF(sort_order IS NULL,1,0), sort_order, added;

 That'll sort NULL values at the end.  Use IF(sort_ORDER IS NULL,0,1)
 to sort them at the beginning instead.

The interface I have made for adding records is probably not idea, I have a input type = text html field, if I leave it blank, NULL does not get inserted, rather a 0 does. I have the default set to '9' now. I would have to make alterations to my admin interface to allow NULL to be input on new record creation. I don't really want to do this.

Okay, but you were the one who (in your previous message) stated that you wanted to know how to sort NULL at one end or the other...


Is there any way to have a ASC sort order that sends 0 to the end, and sorts on 1-9? I know a strange request, but this would be simplest in my case.

It's not really *that* strange, and you can use the same trick described above with a little modification:

ORDER BY IF(sort_order = 0,1,0), sort_order, added


-- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com

Are you MySQL certified? http://www.mysql.com/certification/


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to