469,898 Members | 1,530 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

sort NULL last

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.

Oct 27 '06 #1
3 7418

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

Oct 27 '06 #2

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='' ?

Oct 28 '06 #3

Mark wrote:
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.

Oct 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Eva | last post: by
3 posts views Thread by chellappa | last post: by
48 posts views Thread by Alex Chudnovsky | last post: by
6 posts views Thread by Julia | last post: by
2 posts views Thread by awebguynow | last post: by
reply views Thread by JosAH | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.