List:General Discussion« Previous MessageNext Message »
From:bob pilly Date:February 12 2006 5:44am
Subject:Returning values from an INSERT
View as plain text  
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
  For example my user table has:
  userid <-- auto_increment and primary key
  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!
Yahoo! Photos – NEW, now offering a quality print service from just 8p a photo.
Returning values from an INSERTbob pilly12 Feb
  • Re: Returning values from an INSERTMichael Stassen12 Feb
  • Re: Returning values from an INSERTJonathan Mangin12 Feb