Re: Last ID from database?
| From: | Devrim GUNDUZ | Date: | Wed, 26 Jun 2002 20:06:21 +0000 |
| Subject: | Re: Last ID from database? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20147@lists.php.net to get a copy of this message | ||
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@oper.metu.edu.tr
devrim.gunduz@linux.org.tr
Web : http://devrim.oper.metu.edu.tr
-------------------------------------