Page 1 of 1

ORDER BY question

Posted: Fri Oct 24, 2003 12:38 am
by LonelyProgrammer
Hi all...

Currently I am doing a quiz database. The questions labelling range from simple (like "1", "2") to rather complex ("1a", "1.1.a" and etc.) so in order to sort the question, I use VARCHAR type as the question number, so that when I use "ORDER BY questionumber" at least "1b" will come after "1a" but not after "2".

The problem is that because of this, question "10" is coming right between "1" and "2" (like when you try to sort files by filename in Windows Explorer). Is there any solution (PHP, or mySQL) around this?

Many thanks in advance!

Posted: Fri Oct 24, 2003 3:23 am
by Wayne
put the sql results into an array in php and use natsort() on the array this should put the results in the order you want