Re: [PHP-DB] Last ID from database? From: Devrim GUNDUZ (devrim <email protected>)
Date: 06/26/02

Hi Chris,
On Wed, 26 Jun 2002, Chris Payne wrote:

> Hi there everyone,
>
> How Can I grab just the LAST ID from a database in MySQL with PHP
> easily?

<?
 If(last id == max id)
 {
        // then use this query:
        SELECT max(id) from my_table;
 }
 else if (last id == the last data in the table) {
         // then use this query:
 SELECT id FROM my_table ORDER BY id DESC limit 1;
 }

:-)

Best regards.

-- 

Devrim GUNDUZ

devrim <email protected> devrim.gunduz <email protected>

Web : http://devrim.oper.metu.edu.tr -------------------------------------

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php