I have a simple insert select which insert _TABLE_B_ data in _TABLE_A_ new row
INSERT INTO _TABLE_A_(_USERNAME_,_ID_)
SELECT _USERNAME_,_ID_
FROM _TABLE_B_
I want to insert a row in a table named _TABLE_C_ each time i insert a row in _TABLE_A_ and add the current inserted _TABLE_C_ id in _TABLE_A_.
i'll try to explain it in an other way :
INSERT INTO _TABLE_A_(_USERNAME_,_ID_,_FOREIGN_ID_)
SELECT B._USERNAME_,B._ID_,C._FOREIGN_ID_
FROM _TABLE_B_ AS B
LEFT JOIN _TABLE_C_ AS C
#Insert a row in _TABLE_C_ to retrieve _FOREIGN_ID_...
I'm searching for a single minimal query which have the INSERT SELECT statement like mine because insert select can loop and i have to loop.
FYI : I'm in a stored procedure. I also use prepared statements with dynamic data, and cursors is not suitable for dynamic data select...