Re: Sorting Fields with varchar and Int

From: Date: Thu, 12 Oct 2000 13:19:23 +0000
Subject: Re: Sorting Fields with varchar and Int
References: 1 2 3  Groups: php.windows 
Request: Send a blank email to php-windows+get-3207@lists.php.net to get a copy of this message
Sorry Guys, Using: select ... order by field; to sort by number then by string is more than enough even if the field is varchar(). Due to inefficiency I added the 'order by' clause in the wrong sql statement... :x hehe.. Xon ----- Original Message ----- From: "Zak Greant" <zak@nucleus.com> To: "PHPWIN" <phpwin@hotmail.com>; <php-windows@lists.php.net> Sent: Thursday, October 12, 2000 12:31 PM Subject: Re: [PHP-WIN] Sorting Fields with varchar and Int > Ah - now I understand your dilemma. Creative try at solving the solution. > I can think of two quick (and not super accurate) fixes. > > 1.) select field+0 as num, substr(field,length(num)) as str ... order by > num, str > 2.) select ... order by field+0, soundex(field) > > Good Luck! > --zak > > > ----- Original Message ----- > From: "PHPWIN" <phpwin@hotmail.com> > To: <php-windows@lists.php.net> > Sent: Wednesday, October 11, 2000 11:09 AM > Subject: Re: [PHP-WIN] Sorting Fields with varchar and Int > > > > actually i sorted by using this: > > $sql="select * from table where field like '%".$this."%' > > order by field+0,field+'' "; > > works by sorting the field which is a varchar() by number then as a > string > > again > > however cant seem to get round the string bit > > coz I want to sort by the number 1,2,3.... first then followed by > a,b,c... > > Thanx > > Xon > > > > ----- Original Message ----- > > From: "Zak Greant" <zak@php.net> > > To: "PHPWIN" <phpwin@hotmail.com> > > Cc: <php-windows@lists.php.net> > > Sent: Thursday, October 12, 2000 2:27 AM > > Subject: Re: [PHP-WIN] Sorting Fields with varchar and Int > > > > > > > order by field_name > > > > > > --zak > > > > > > At 07:23 PM 10/11/00 +0800, PHPWIN wrote: > > > >Hi > > > > Does anyone know how to sort these columns in MySql from > > > >+------+ > > > > I 1b I > > > >+------+ > > > > I 1c I > > > >+------+ > > > > I 2b I > > > >+------+ > > > > I 1a I > > > >+------+ > > > > I 2a I > > > >+------+ > > > > > > > >to this > > > >+------+ > > > > I 1a I > > > >+------+ > > > > I 1b I > > > >+------+ > > > > I 1c I > > > >+------+ > > > > I 2b I > > > >+------+ > > > > I 2a I > > > >+------+ > > > > > > > >if the fields are varchar() > > > > > > > >cheers > > > >Xon > > > > > > > > > > -- > > PHP Windows Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > > For additional commands, e-mail: php-windows-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.windows (#3207) next »