Hi I want to use an id reference that had just been created in a different table

I have an insert query that adds a new user to the users table the t_id is auto generated I want to use the t_id value in a new query that runs after the user has been added is there a way of retrieving this data?

thanks

M

Can you please be more clear? I am not sure what you are asking. Also, are you storing this info in an SQL Query?

What db are you using? If it's MS SQL you can use OUTPUT when inserting.
Read here for OUTPUT: http://msdn.microsoft.com/en-us/library/ms177564.aspx

Another way to do this, if you can't use OUTPUT is to add a datetime field (like date_added) and pass a datetime value to that field that you've stored in a variable. Depending on the number of records inserted simultaneously this can cause problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.