On Mon, May 21, 2001 at 03:58:10PM +0200, Viktor van den Berg wrote:
>
> Hi!
>
> I like to know how to retrieve the record id after an "insert into" query.
> I have the table "user" containing two columns: UID (auto_increment) and
> USERNAME. After I have added a new user (using "insert into user (uid)
> ....etc.) I like to know the UID of the new record.
>
> I can set the record pointer to the last record, but if anybody else also
> inserts a record at the same time, I think this will give a problem.
>
> Can anybody give me a suggestion?
Look at the MySQL manual. Reference >> INSERT, look for mentioning of
AUTO_INCREMENT fields, and specifically, for a reference to the
LAST_INSERT_ID() function.
Simple, isn't it? :) All referenced in the manual, if you take the time
to check what the manual has to say about 'INSERT'.. :)
G'luck,
Peter
--
This inert sentence is my body, but my soul is alive, dancing in the sparks of your
brain.
---------------------------------------------------------------------
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