dbTalk Databases Forums  

sort NULL last

mailing.database.mysql mailing.database.mysql


Discuss sort NULL last in the mailing.database.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mark
 
Posts: n/a

Default sort NULL last - 10-26-2006 , 11:17 PM






I have a mysql query, "SELECT * FROM task ORDER BY duedate ASC", where
"duedate" is a unix_timestamp and can be NULL. I want any NULL results
to be at the end of the list, how might I do this? Thanks.


Reply With Quote
  #2  
Old   
strawberry
 
Posts: n/a

Default Re: sort NULL last - 10-27-2006 , 04:30 AM







Mark wrote:
Quote:
I have a mysql query, "SELECT * FROM task ORDER BY duedate ASC", where
"duedate" is a unix_timestamp and can be NULL. I want any NULL results
to be at the end of the list, how might I do this? Thanks.
Have a look at the bottom of this post:

http://groups.google.com/group/alt.p...0d115e698ca173



Reply With Quote
  #3  
Old   
Mark
 
Posts: n/a

Default Re: sort NULL last - 10-28-2006 , 04:51 PM




strawberry wrote:
Quote:
Mark wrote:
I have a mysql query, "SELECT * FROM task ORDER BY duedate ASC", where
"duedate" is a unix_timestamp and can be NULL. I want any NULL results
to be at the end of the list, how might I do this? Thanks.

Have a look at the bottom of this post:

http://groups.google.com/group/alt.p...0d115e698ca173
IF(l_name IS NULL or l_name='', 1, 0)
AS isnull
FROM students
ORDER BY isnull ASC, l_name ASC;";

what is the 1,0 for after name='' ?



Reply With Quote
  #4  
Old   
Mark
 
Posts: n/a

Default Re: sort NULL last - 10-28-2006 , 05:08 PM




Mark wrote:
Quote:
strawberry wrote:
Mark wrote:
I have a mysql query, "SELECT * FROM task ORDER BY duedate ASC", where
"duedate" is a unix_timestamp and can be NULL. I want any NULL results
to be at the end of the list, how might I do this? Thanks.

Have a look at the bottom of this post:

http://groups.google.com/group/alt.p...0d115e698ca173

IF(l_name IS NULL or l_name='', 1, 0)
AS isnull
FROM students
ORDER BY isnull ASC, l_name ASC;";

what is the 1,0 for after name='' ?
ah.. nvm

IF(expr1,expr2,expr3)

If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns
expr2; otherwise it returns expr3. IF() returns a numeric or string
value, depending on the context in which it is used.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.