jasonc Posted June 6, 2008 Share Posted June 6, 2008 sorting results got from mysql. i wish to sort results by the columns ID then by NUMBER, both with the highest numbers first. i have this mysql code so far but it firstly sorts the ID column but has 99 above 990 ! can i sort so it is strict number order? select * from `list` ORDER BY `number` DESC LIMIT 600 Quote Link to comment Share on other sites More sharing options...
luca200 Posted June 6, 2008 Share Posted June 6, 2008 It would be very strange if it sorted the id columns, given you wrote "ORDER BY number". Your clause should be ORDER BY id desc, `number` desc, but if columns are not numeric, of course you'll get 99 before 990. In that case you should do this SELECT *, cast(id as integer) as numid, cast(`number` as integer) as numnumber ORDER BY numid desc, numnumber desc Quote Link to comment Share on other sites More sharing options...
jasonc Posted June 6, 2008 Author Share Posted June 6, 2008 ok i see how this works.. but where is the table info it is searching? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.