Re: Highest ID
| From: | rilson at fabricadeideias dot com | Date: | Tue, 29 Aug 2000 14:57:01 +0000 |
| Subject: | Re: Highest ID | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-2443@lists.php.net to get a copy of this message | ||
You can use
Select max(increment_field) from table
or
Select increment_field from table order by increment_field desc limit 1
I think the first one is faster...
Hope it helps,
Rilson
> Hi,
>
> I've got a table whith a primary key as auto incrementing field.
> I want to know what the highest ID is.
> I know you can use mysql_insert_id but that is only after an insert. I
> want to know it whithout doing an insert which gives me an $insert_id,
> delete that $insert_id and nowing that the highest is $insert_id - 1;
>
> any suggestions ?
>
> J.S. de Boer