From: Michael Widenius Date: March 15 1999 4:58pm Subject: Re: Auto-Increment List-Archive: http://lists.mysql.com/mysql/272 Message-Id: <14061.15324.362854.564628@monty.pp.sci.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit >>>>> "Oliver" == Oliver Artelt writes: Oliver> On Sun, 14 Mar 1999, Tauren Mills wrote: >> >> >> 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 >> Oliver> Lock the table before your INSERT and SELECT statement. Another way is to Oliver> stamp the rows yourself, e.g. functions related to RPC. Oliver> oli. Hi! No, there is no need to lock the rows in the above case. The above query is automaticly transformed to: SELECT * FROM tbl_name WHERE auto_col = LAST_INSERT_ID() and the LAST_INSERT_ID() variable is thread safe (will not be affected by other clients) Regards, Monty