Re: First and Last ID of a table

From: Date: Wed, 11 Jul 2007 20:58:43 +0000
Subject: Re: First and Last ID of a table
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-43774@lists.php.net to get a copy of this message
On Wed, 11 Jul 2007, Matt Leonhardt wrote:
<tg-php@gryffyndevelopment.com> wrote in message news:20070711201352.905EE10A008@spaceymail-a2.g.dreamhost.com...
SELECT MIN(id), MAX(id) FROM mytable
As an aside, is you are using associative arrays, be sure to use the following keys: $array['MIN(id)'] and $array['MAX(id)'] Just something I figured out recently :)
or use select min(id) min, max(id) max from mytable then access as $array['min'] and $array['max'] ---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
beckman@angryox.com                                 http://www.angryox.com/
--------------------------------------------------------------------------- ** PLEASE NOTE PurpleCow.com IS NOW AngryOx.com DO NOT USE PurpleCow.com ** ** PurpleCow.com is now owned by City Auto Credit LLC as of May 23, 2007 ** ---------------------------------------------------------------------------

« previous php.db (#43774) next »