How to output items in Order in MySQL?
Posted
by RailsRor
on Stack Overflow
See other posts from Stack Overflow
or by RailsRor
Published on 2010-04-05T07:28:59Z
Indexed on
2010/04/05
7:33 UTC
Read the original article
Hit count: 188
mysql
I have a column called "menu_order" which has no default value. When I select the contents of this column using the following select statement:
SELECT * FROM categories ORDER BY menu_order ASC
It lists the category items that have nothing as their menu order first and then the one's that have 1's and 2's and 3's. Is there any way to prevent SQL from take nothing to come before numbers when I am trying to list things in order?
So for example, if I have:
cat_name | menu_order
----------------------
Lunch | 1
Dinner |
And I perform my query, the output should be:
Lunch Dinner
Not:
Dinner Lunch
© Stack Overflow or respective owner