Forum Moderators: coopster
I am trying to INSERT VALUES in two tables
(in one shot)
but would like passing the ID (auto incremented) from the fist one to the second one
how can I do it by modifying the following
that I borrowed here!
actually I think I have to find a way to find what is the a_table auto incremented ID
then passing it to the second table but how?
$query = "insert INTO a_table (id, val1, val2) VALUES ('', '$form_val1', '$form_val2');
insert INTO b_table (id, val3, val4) VALUES ('', '$form_val3', '$form_val4');";
but in b-table I need to pass the a_table ID value
thanks
regards
I found the above to work. You will need an auto increment for the second table plus a field for the ID from the first table.
So do the first insert then roll onto a new one. I think you will struggle if you try to do both at the same time. If you do know of a better way, please post it. :)