On Tuesday 01 April 2003 08:57, Noel Wade wrote: > Say I have a table with an auto_increment field that is being used at the > primary key. > > When I insert a new record, is there any way to easily grab the primary key > value for that new record? I had another unique field that I was > originally going to use to do a select statement; but now that's been > changed to a non-unique field. > > Is there some way to easily snag the record that has just been inserted (or > the primary key from this new record)?
Take a look at LAST_INSERT_ID() function: http://www.mysql.com/doc/en/Miscellaneous_functions.html > Or is it easier and better to determine the auto_increment value BEFORE > doing the insert (and manually specifying the value for the primary key in > the insert statement)? -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Egor Egorov / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]