make your column of type int column

-----Original Message-----
From: Ben Ramsey [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 05, 2004 7:52 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP] Re: MySQL: Order by


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;';

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--------------------------------------------------------------------
Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to