Hi all, I couldn't find this in the forum though I'm sure it's been asked before. I need to get a primary key (ID) from one INSERT to use in the next INSERT. What's the best and most efficient way to do this?
For example:
INSERT INTO one_table (one_field) VALUES ($one_value);
INSERT INTO two_table (two_field, two_field_str) VALUES (????, $two_field_str);
The ???? needs to be the primary key (auto_increment) from the INSERT before into one_table.
I'm currently adding it, then doing a SELECT to get the value based on a particular field, in DESC order. I'm guessing there is a better way. Help?