On Tuesday 28 August 2001 12:36, [EMAIL PROTECTED] wrote:
> When you have just inserted a record into a table that autoincrements the
> primary key,
> is there a way of retrieving the id assigned at the same time? I'm using
> ASP to write the
> code in question , and I'm trying to find a better solution that looking at
> the max key value
> just before/after in code,
You mean using SELECT LAST_INSERT_ID() ?
> and praying no other query was run at the same
> time.
Try locking the table for writes just before your insertion, do the insert,
SELECT LAST_INSERT_ID() and release the lock. This should prevent another
insert being carried out before you retrieve the ID.
HTH
Ian Barwick
--
Ian Barwick - Developer - [EMAIL PROTECTED]
akademie.de asp GmbH - http://www.akademie.de
"To query tables in a MySQL database is more fun than eating spam"
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php