Re: mysql + PHP

From: Date: Thu, 15 Jun 2006 12:10:04 +0000
Subject: Re: mysql + PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-238075@lists.php.net to get a copy of this message
At 2:14 PM +0800 6/15/06, weetat wrote: >Hi all, > > I have SQL query , for example , Select country , name from tbl_chassis order by country. > > The problem of the sql statement is that , if there are empty value in country field , it be > sorted first . > >How to do sorting the empty value last >? I can cp() function to do this ? or any mysql function to use? > >Thanks >- weetat From mysql/null: <http://dev.mysql.com/doc/refman/5.0/en/working-with-null.html> "If you want to have NULL values presented last when doing an ORDER BY, try this: SELECT * FROM my_table ORDER BY ISNULL(field), field [ ASC | DESC ] " You can also try other combinations, such as (I haven't tried it): SELECT country , name FROM tbl_chassis ORDER BY country AND IS NOT NULL tedd -- ------------------------------------------------------------------------------------ http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#238075) next »