depending on your database, you can retrieve the identity value when it's created.
SQL Server has @@identity mySQL has last_inserted_id http://weblogs.macromedia.com/cantrell/archives/2004/11/safely_selectin.cfm http://www.webtricks.com/sourcecode/code.cfm?CodeID=23 there's a gaggle of info out there on the various techniques that the various RDBMSs offer. Google is your budy :) On 3/9/06, Chris Mueller <[EMAIL PROTECTED]> wrote: > Here's a question I've been wrestling wtih. > > Suppose that there is an HTML form to create a new user. When the form > is submitted, that user's information is added to the 'user' table. > The table uses an auto-increment integer for its primary key/user id, > so I'd like to grab that value for the newly created user. > > I've been using queries like this one: "SELECT MAX(user_id) FROM > users", but I worry that if two users are created at the same time, > then my query might give me the user id of the wrong user. > > Is there a better way to do this? Or maybe I shouldn't even worry about this? > > Thanks. > Chris > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:234923 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

