I'm in a transaction and I want to execute some INSERT in some tables.
My purpose is to INSERT in the table2 the `ID (an AUTO_INCREMENT Primary Key, not explicitally inserted) of the first table in the second one, during the same transaction process.
INSERT INTO table1(
column_a,
column_b,
column_c
) VALUES (
value_1,
value_2,
value_3
);
INSERT INTO table2(
column_d,
column_e,
column_f
) VALUES (
value_1,
value_2,
value_3 <-- AUTO_INCREMENT Primary Key of table1
);
The ID of table1 not exists until the process is ended but I think that MYSQL stores somewhere the auto incremented ID's menawhile checks if all is ok before writing in the tables.
Is there a way to catch these ID's and accomplish my target?
Thanks.