>> 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. Jespersen | 15 Mar |
| • Re: Do something about the spam, or this list is useless :( | Karl Pielorz | 15 Mar |
| • Re: Do something about the spam, or this list is useless :( | Robert Hazeltine | 15 Mar |
| • Re: Do something about the spam, or this list is useless :( | Dennis | 15 Mar |
| • Re: Do something about the spam, or this list is useless :( | Dennis | 15 Mar |
| • Re: Do something about the spam, or this list is useless :( | Karl Pielorz | 15 Mar |
| • Re: Do something about the spam, or this list is useless :( | Fred Lindberg | 15 Mar |
| • Re: Do something about the spam, or this list is useless :( | Ed Carp | 15 Mar |
| • Re: Do something about the spam, or this list is useless :( | Martin B. Jespersen | 16 Mar |
| • Can I get a field when inserting a row? | Jochen Haeberle | 16 Mar |
| • Re: Can I get a field when inserting a row? | Thimble Smith | 16 Mar |
| • Re: Can I get a field when inserting a row? | Jochen Haeberle | 16 Mar |
| • Re: Can I get a field when inserting a row? | Thimble Smith | 16 Mar |
| • Re: Do something about the spam, or this list is useless :( | Micheal Mc Evoy | 16 Mar |
| • Re: Do something about the spam, or this list is useless :( | Fred Lindberg | 16 Mar |
| • Re: Can I get a field when inserting a row? | Jochen Haeberle | 16 Mar |
| • Re: Can I get a field when inserting a row? | Ed Carp | 17 Mar |