Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL ORDER by `no` with NULLs at the end

I have got a MySql query that orders me results by no column (int, can be null). Simple example:

SELECT * FROM table ORDER BY no ASC

I would like to get a resultset sorted like

1, 2, 3, 10, 52, 66, NULL, NULL, NULL

but I get

NULL, NULL, NULL, 1, 2, 3, 10, 52, 66

Is it possible with SQL query ?

like image 520
hsz Avatar asked Dec 10 '09 11:12

hsz


1 Answers

Could you try this?

ORDER BY ISNULL(no),no;
like image 78
YOU Avatar answered Oct 18 '22 09:10

YOU