Re: Highest ID
| From: | Jon Evans | Date: | Tue, 29 Aug 2000 10:23:05 +0000 |
| Subject: | Re: Highest ID | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2433@lists.php.net to get a copy of this message | ||
Hi Boer de JS,
On Tue, Aug 29, 2000 at 12:02:49PM +0200, Boer de JS wrote:
> 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 ?
SELECT MAX(ID) FROM TABLE;
But make sure you aren't using that result for an insert if there is
any possibility that another user might also be adding stuff to the
table at the same time as you.
Jon.
--
Jon Evans / Red Internet Ltd. / +44 1869 337977