472,119 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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 7476

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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.