What about a number field w/zero fill?
On Thu, 30 Aug 2001, Adams, Bill TQO wrote:
> Date: Thu, 30 Aug 2001 08:48:11 -0700
> From: Adams, Bill TQO <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: order by number
>
> If the column is an int then it will order it numerically. Other wise you have to
>cast it. And dont for get the difference between ORDER BY x ASC and ORDER BY x DESC.
>
> --Bill
>
>
> DROP TABLE IF EXISTS test;
> CREATE TABLE test ( i int, c char(20));
> INSERT INTO test VALUES
> ( 1, '5' ),
> ( 2, '4' ),
> ( 3, '3' ),
> ( 4, '2' ),
> ( 5, '1' ),
> ( 1, '5' );
>
> SELECT '-- Natural Order';
> SELECT * FROM test;
> SELECT '- ORDER by INT';
> SELECT * FROM test ORDER BY i;
> SELECT '- ORDER BY cast char-- ';
> SELECT *, ( c + 0) AS o_col FROM test ORDER BY o_col;
>
>
> Philip Montgomery wrote:
>
> > When doing a select with an order by clause, how do you make mysql list the items
>in correct numberical order. Normally, when I run the command mysql will list 1000
>before 200 because of the initial digit. How do I correct this?
> >
> > Thanks,
> >
> > Phil
> >
> > Get 250 color business cards for FREE!
> > http://businesscards.lycos.com/vp/fastpath/
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> > http://www.mysql.com/manual.php (the manual)
> > http://lists.mysql.com/ (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
> --
> Bill Adams
> TriQuint Semiconductor
>
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
Sincerely,
William Mussatto, Senior Systems Engineer
CyberStrategies, Inc
ph. 909-920-9154 ext. 27
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php