List:General Discussion« Previous MessageNext Message »
From:Ed Carp Date:March 16 1999 11:32pm
Subject:Re: Can I get a field when inserting a row?
View as plain text  
>> The last insert id is stored *per thread*, not per table.  When
>> you select LAST_INSERT_ID(), it checks your thread for the most
>> recent ID inserted.  This is critical for correct performance of
>> programs, because more than one thread can be updating a table.
>> If LAST_INSERT_ID() returned the most recent ID for a table, you
>> could not be sure it belonged to the row you just inserted or a
>> row that someone else inserted.


You could also add a timestamp field to the table, then do "select ID from
table order by timestamp_field desc limit 1", then suck off the ID that way,
but again, that's not a guarantee, due to the concurrent threads issue.

Maybe if you explain exactly *why* you want to get the ID of the last row,
we might be able to assist you better?

Thread
Do something about the spam, or this list is useless :(Martin B. Jespersen15 Mar
  • Re: Do something about the spam, or this list is useless :(Karl Pielorz15 Mar
    • Re: Do something about the spam, or this list is useless :(Robert Hazeltine15 Mar
    • Re: Do something about the spam, or this list is useless :(Dennis15 Mar
  • Re: Do something about the spam, or this list is useless :(Dennis15 Mar
  • Re: Do something about the spam, or this list is useless :(Karl Pielorz15 Mar
Re: Do something about the spam, or this list is useless :(Fred Lindberg15 Mar
Re: Do something about the spam, or this list is useless :(Ed Carp15 Mar
  • Re: Do something about the spam, or this list is useless :(Martin B. Jespersen16 Mar
    • Can I get a field when inserting a row?Jochen Haeberle16 Mar
      • Re: Can I get a field when inserting a row?Thimble Smith16 Mar
        • Re: Can I get a field when inserting a row?Jochen Haeberle16 Mar
          • Re: Can I get a field when inserting a row?Thimble Smith16 Mar
    • Re: Do something about the spam, or this list is useless :(Micheal Mc Evoy16 Mar
Re: Do something about the spam, or this list is useless :(Fred Lindberg16 Mar
Re: Can I get a field when inserting a row?Jochen Haeberle16 Mar
Re: Can I get a field when inserting a row?Ed Carp17 Mar