RE: [PHP] order by ASC

From: Date: Wed, 20 Jan 2010 00:39:46 +0000
Subject: RE: [PHP] order by ASC
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-301231@lists.php.net to get a copy of this message
On Tue, 2010-01-19 at 16:16 -0800, Daevid Vincent wrote: > http://www.webdeveloper.com/forum/showthread.php?t=101174 > > You could do it like this too... > > ORDER BY rollnumber + 0 ASC > > And if you just got the data out in mysql (no ORDER BY -- which can be slow > in mysql), you could use PHP's sort as well... > > http://php.net/manual/en/function.natsort.php > > > -----Original Message----- > > From: Robert Cummings [mailto:robert@interjinn.com] > > Sent: Saturday, January 16, 2010 9:37 PM > > To: John Taylor-Johnston > > Cc: PHP-General > > Subject: Re: [PHP] order by ASC > > > > John Taylor-Johnston wrote: > > > Did some googling. This worked: > > > ORDER BY CAST(rollnumber AS SIGNED) > > > > > > What is the difference? My problem in the meanwhile must be > > my version > > > of MySQL? > > > > You could have skipped quotes altogether. The difference is > > that you are > > referencing a field name, not a string value. > > > > Cheers, > > Rob. > > -- > > http://www.interjinn.com > > Application and Templating Framework for PHP > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > I've always found that ordering is much faster in MySQL than PHP. You use quite a lot of memory sorting in PHP as well, as you first have to load the whole result set into an array, which is additional to any memory used in the result set by PHP and MySQL anyway. Thanks, Ash http://www.ashleysheridan.co.uk

« previous php.general (#301231) next »