Re: Querying for MAX

From: Date: Thu, 13 Jun 2002 03:52:50 +0000
Subject: Re: Querying for MAX
References: 1  Groups: php.db php.general 
Request: Send a blank email to php-general+get-101888@lists.php.net to get a copy of this message
Hi César, As others have obviously pointed out using MAX() is the way to go. Need I mention that you can also insert values of your own making into an auto_increment column as long as they are not already used by some other record. In your case since you have old records with IDs of their own making, you can probably insert them at the beginning before the newer records actually use an auto - generated ID. Also by using mysql_insert_id () in PHP you can get the last inserted auto-increment ID. -Srini -- http://symonds.net/~sriniram ----- Original Message ----- From: "César Aracena" <caracena@infovia.com.ar> To: "'PHP DB List'" <php-db@lists.php.net>; "PHP General List" <php-general@lists.php.net> Sent: Thursday, June 13, 2002 12:06 AM Subject: [PHP-DB] Querying for MAX I'm sorry if this mensaje is posted twice. I sent it yesterdays, but then my ISP had problems with e-mail and I lost dozens of them and don't know if sent OK. Hi all, What I'm trying to do here is not inside PHP nor MySQL books I have. I need to query the DB to look the max result in a column. That is, if I have affiliate members with ID going from 1 to 10, get the query to know that the last member added was 10 so I can add member 11 without using auto_increment, because I need to insert old members too which already have ID numbers. Is that possible? Thanks in advance, Cesar Aracena <mailto:webmaster@icaam.com.ar> CE / MCSE+I Neuquen, Argentina +54.299.6356688 +54.299.4466621

« previous php.general (#101888) next »