jdubwelch Posted October 19, 2007 Share Posted October 19, 2007 i have a mysql db with a column called "section". I want it to sort ascending, but it's not sorting the way i want it too. This is how it's sorting. 10 11 12 12:1-3 17:15-22 18:16-33 1:1-2 1:3-31 2 20:1-2 21:9-14 22:1-2 22:3-19 24:61 Is there a way I can get it to sort it so it'd be: 1:1-2 1:3-31 2 11 12 12:1-3 17:15-22 18:16-33 20:1-2 21:9-14 22:1-2 22:3-19 24:61 Quote Link to comment Share on other sites More sharing options...
jdubwelch Posted October 19, 2007 Author Share Posted October 19, 2007 okay, so i get it to sort by the first number with with, but i don't know about the ones after the ":"... ideas? SELECT section FROM `media` ORDER BY (section +0) 1:3-31 1:1-2 2 3:1-24 3:1-24 4 6:1-22 6:1-22 7 8 8:6-12 9 9:18-27 10 11 12 12:1-3 13-14 14:17-24 15 15 16-17 17-18 17:15-22 18:16-33 20:1-2 21:9-14 22:3-19 22:1-2 24:61 Quote Link to comment Share on other sites More sharing options...
jdubwelch Posted October 19, 2007 Author Share Posted October 19, 2007 SELECT section FROM `media` ORDER BY(section +0), SUBSTR(section, 3) That does the trick. 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.