----- Original Message ----- From: "bob pilly" <[EMAIL PROTECTED]> To: <mysql@lists.mysql.com> Sent: Sunday, February 12, 2006 12:44 AM Subject: Returning values from an INSERT
> Hi everyone, im new to SQL and have a question that someone can hopefully answer > > If i am inserting a new record into a table that has an auto_increment field in it, is it possible to get the value of that field returned automatically instead of having to do a SELECT.. > > For example my user table has: > > userid <-- auto_increment and primary key > username > > So if i: > > Insert into user (username) VALUES ('Test User'); > > i dont know what userid was assigned to that particular user and are having to: > > SELECT userid FROM user where username = 'Test User'; > > to get the id. > > Is that the only way to do it? > > hope it isnt a stupid question and thanks for any help in advance! > > Cheers > > Bob > > > --------------------------------- > Yahoo! Photos - NEW, now offering a quality print service from just 8p a photo. Is username (as opposed to fname, lname) unique? If so, perhaps you can make that the primary key and bag id. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]