List:General Discussion« Previous MessageNext Message »
From:Moon's Father Date:June 2 2008 6:08am
Subject:Re: Obtaining AUTOINCREMENT of just inserted record, but...
View as plain text  
set @id = last_insert_id();
select @id;

On Fri, May 30, 2008 at 10:45 PM, D Hill <d.hill@stripped> wrote:

> Disreguard my message. I just saw Ben Clewett's response and that has
> cleared my question up. Sorry to bother.
>
> On Fri, 30 May 2008 at 09:38 -0400, mdykman@stripped confabulated:
>
>  I'm not clear what you mean when you distinguish between JUST inserted
>> and LAST inserted.  In any case, the only mechanism available is
>> SELECT LAST_INSERT_ID().  MySQL does have a concept of sessions, so if
>> 2 users are submitting at the same moment, that database activity
>> would be occurring across two distinct connections and the result of
>> the call would reflect the last insert on that same connection.  It's
>> perfectly safe and will give you the value that you are looking for.
>> (If it didn't, ~70% of the apps on the web would be irretrievably
>> broken).
>>
>> - michael dykman
>>
>> On Fri, May 30, 2008 at 9:27 AM, Miguel Cardenas <renito73@stripped>
>> wrote:
>>
>>> Hello list
>>>
>>> I need to retrieve the AUTOINCREMENT field from the just inserted record,
>>> note that I say JUST INSERTED and not LAST INSERTED.
>>>
>>> It is for a website that accepts forms submitted by users, but it may
>>> occur
>>> in some time that two or more forms are submitted simultaneously by
>>> different users, so not necessarily the last inserted could be the just
>>> inserted, or yes?
>>>
>>>
>>> Thanks for any help
>>>
>>>
>>
>>
>> --
>> - michael dykman
>> - mdykman@stripped
>>
>> - All models are wrong. Some models are useful.
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe:
>> http://lists.mysql.com/mysql?unsub=1
>>
>>
>>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=1
>
>


-- 
I'm a MySQL DBA in china.
More about me just visit here:
http://yueliangdao0608.cublog.cn

Thread
Obtaining AUTOINCREMENT of just inserted record, but...Miguel Cardenas30 May
  • Re: Obtaining AUTOINCREMENT of just inserted record, but...Michael Dykman30 May
    • Re: Obtaining AUTOINCREMENT of just inserted record, but...D Hill30 May
    • Re: Obtaining AUTOINCREMENT of just inserted record, but...D Hill30 May
      • Re: Obtaining AUTOINCREMENT of just inserted record, but...Moon's Father2 Jun
  • Re: Obtaining AUTOINCREMENT of just inserted record, but...Ben Clewett30 May
    • Re: Obtaining AUTOINCREMENT of just inserted record, but...Werner Van Belle30 May