Re: MySQL: Order by

From: Date: Thu, 05 Feb 2004 05:51:42 +0000
Subject: Re: MySQL: Order by
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-176867@lists.php.net to get a copy of this message
I assume "number" is a column name in your table. If so, I'm also guessing that it's probably of a varchar (or some other character type) datatype. Here's why: if it's a character, then ORDER BY will sort alphabetically. The way it sorts number alphabetically is rather odd, but it makes sense in an alphabetical way. If it is character data, then it should order like this: 1 10 11 12 13 2 3 4 ... To correct it, put a zero at the beginning of your single digits: 01 02 03 ... 10 11 12 That will order it correctly. Otherwise, change the number column to type int, and it should work just fine. Hope that answers your question, and, yes, this is more of a MySQL question. ;-) -Ben John Taylor-Johnston wrote:
This is probably a MySQL question, and maybe an easy question, but I'm here to learn <|:) When I order by number, it echoes 1,2,3,4,5,6,7,8,9,10 and hten jumps to 100...199 before it comes back to 11-19. Any way of ordering that differently? $sql = 'SELECT * FROM '.$table.' ORDER BY number desc;';


« previous php.general (#176867) next »