bob pilly wrote:
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

LAST_INSERT_ID() 
<http://dev.mysql.com/doc/refman/4.1/en/information-functions.html>

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to