On Tuesday 28 August 2001 13:55, Harald Fuchs wrote:
> In article <01082813314101.11299@redgrave>,
>
> Ian Barwick <[EMAIL PROTECTED]> writes:
> > 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.
>
> This is not necessary.  LAST_INSERT_ID is client-specific; thus you
> get guaranteed the ID of the last INSERT issued by yourself,
> regardless of what other clients might do in the meantime.

Aha, thanks, nice to know. I tend to assume the worst with MySQL (slight 
personal prejudice due to lack of referential integrity etc., please don't 
flame, I think it is excellent otherwise, else I would't be using it ;-) 

Note to self: RTFM more often...

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

Reply via email to