MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Tauren Mills Date:March 15 1999 2:45am
View as plain text  

After reading the manual, I have a question about Auto-Increment...

The manual says that I can use this query to find out the value of the most
recent AUTO_INCREMENT field:

SELECT * FROM tbl_name WHERE auto_col IS NULL

If I use this immediately after inserting a row, am I guaranteed that this
will return the value that I just inserted?  Or is it possible for another
user accessing the same database to insert another row right after my row
was inserted, but prior to this Select?  To use this correctly, do I need to
lock the table prior to the insert and the select?

I am doing this from via the twz Java JDBC driver.  Is there another simpler
approach I can take?  I cannot use mysql_insert_id().


Auto-IncrementTauren Mills15 Mar
  • Re: Auto-IncrementOliver Artelt15 Mar
    • Re: Auto-IncrementMichael Widenius15 Mar