MySQL sorting problem with null values

Codes here !

Moderators: macek, egami, gesf

Post Reply
Elena Mitovska
New php-forum User
New php-forum User
Posts: 13
Joined: Tue Nov 12, 2002 12:11 pm
Location: Ukraine
Contact:

Post by Elena Mitovska » Tue Feb 04, 2003 11:11 pm

You need to write SQL querylike this:

SELECT username, last_order FROM table ORDER BY
isNULL(last_order), last_order

It will return:

Puffball 1999-03-30
Bowser 1999-10-01
Slim 2000-02-28
Buffy NULL
Fang NULL

Or like this to get the result in descending order:

SELECT username, last_order FROM table ORDER BY
isNULL(last_order), last_order desc

Slim 2000-02-28
Bowser 1999-10-01
Puffball 1999-03-30
Buffy NULL
Fang NULL

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests