searls03 Posted April 1, 2012 Share Posted April 1, 2012 ok, how do I add an auto incremented value to another table at the same time the value is created. so I will do a query to insert into db, and it creates auto incremented value of 1, then I need this value to also be put into another table just as text. how do I go about doing this? I need this all in one query. Quote Link to comment https://forums.phpfreaks.com/topic/260147-auto-increment-values/ Share on other sites More sharing options...
Psycho Posted April 1, 2012 Share Posted April 1, 2012 I need this all in one query. Why do you need it to be done in one query? Just do the insert into the first table, then get the id using mysql_insert_id(). Then do your Insert into the second table using that id. Quote Link to comment https://forums.phpfreaks.com/topic/260147-auto-increment-values/#findComment-1333348 Share on other sites More sharing options...
jcbones Posted April 1, 2012 Share Posted April 1, 2012 Or, you could use a trigger. Quote Link to comment https://forums.phpfreaks.com/topic/260147-auto-increment-values/#findComment-1333349 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.