There are a ton of different ways to handle this. Starting with using a CFtransaction tag around the two queries down to just not auto-generating it through the database and inserting the value via queries. Some databases offer functions for grabbing the autogenerated ID that was inserted, that might be the best place to start looking.
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:234924 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

