MySQL sorting problem with null values

Codes here !

Moderators: egami, macek, 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:

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
best regards,
Elena Mitovska,
wed_developer,
AlarIt company
http://www.alarit.com

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest