PDA

View Full Version : MySQL ORDERBY not ordering


mangofreak
08-19-2009, 07:15 PM
Hi Guys, I have a funny --- not really -- problem. I have a mySQL DB table, on it there are 6 fields for the intMenuID, txtMenuItem, bitShow, intOrder, bitTitle, intChild.

My query is the following

SELECT intMenuID, txtMenuItem, bitShow, intOrder, bitTitle, intChild
FROM tblMenu
ORDER BY tblMenu.intOrder ASC


The idea is that the menu items can be ordered using the intOrder field. So I can list my main menu items as:
1
2
3
4
but my menu items are showing as
2
1
3
4

However, my intChild items that use the same ordering system show properly.

Any idea as to why? Did you guys experience something like this?

bee80
08-19-2009, 07:37 PM
try this :

SELECT intMenuID, txtMenuItem, bitShow, intOrder, bitTitle, intChild
FROM tblMenu
ORDER BY intOrder ASC


i dont think you need to specify the table in the ORDER BY part as your not joining tables with that query

mangofreak
08-19-2009, 08:18 PM
Nope. That's not it. I think that somehow, mySQL gets messed up when I try using intOrder for the txtMenuItem that by using the chaeckbox can decide if it is a child or a parent item. In both cases parent and child items can be sorted independently. It should be working but it doesn't. So I am tryiong to use 2 tables to accomplish the same.

edbr
08-20-2009, 01:55 AM
it maust be some kind of conflict as a whole i think the code is fine im sure if you use this on a seperate test page it will echo out fine
using
ORDER BY intOrder ascending will be default,