Click here to get back home

sort NULL last

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
sort NULL last Mark 10-27-2006
Get Chitika Premium
Posted by Mark on October 27, 2006, 12:17 am
Please log in for more thread options
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.


Posted by strawberry on October 27, 2006, 5:30 am
Please log in for more thread options

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.php.sql/browse_thread/thread/ad3bc576fb0631b7/960d115e698ca173?lnk=st&q=%22AS+ISNULL%22&rnum=3#960d115e698ca173


Posted by Mark on October 28, 2006, 5:51 pm
Please log in for more thread options

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.php.sql/browse_thread/thread/ad3bc576fb0631b7/960d115e698ca173?lnk=st&q=%22AS+ISNULL%22&rnum=3#960d115e698ca173

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


Posted by Mark on October 28, 2006, 6:08 pm
Please log in for more thread options

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.php.sql/browse_thread/thread/ad3bc576fb0631b7/960d115e698ca173?lnk=st&q=%22AS+ISNULL%22&rnum=3#960d115e698ca173
>
> 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.


Similar ThreadsPosted
MySQL 4.0.17 data scrambles, not-null fields become null, etc. July 3, 2006, 3:38 pm
not null column with null defaults July 29, 2006, 1:00 am
Sort, Limit then Sort August 11, 2005, 3:55 pm
Null Value August 31, 2005, 1:35 pm
LIKE and IS NOT NULL February 1, 2006, 2:28 am
not null not taking January 24, 2006, 2:18 pm
Really going crazy with NOT NULL January 24, 2006, 3:44 pm
SQL sort (Order by) August 10, 2006, 6:05 am
sort asc w/ most recent August 20, 2006, 5:01 am
Checking a field for NULL February 13, 2006, 3:05 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap