Due to the character limit, I couldn't choose a good title My topic is a bit more complicated but I will explain it simplified here.
i have 3 table
the entity table
| id | name
|----|------
| 1 | X
the entity_color table
| id | entID (foreign key entity.id) | color
|----|-------------------------------|-------
| 1 | 1 | blue
|----|-------------------------------|-------
| 2 | 1 | red
the stock_room table
| id | entColID (foreign key entity_color.id) | quntity
|----|----------------------------------------|----------
| 1 | 1 | 10
|----|----------------------------------------|----------
| 2 | 2 | 20
How can I insert this 5 rows ( 1 rows into entity + 2 rows into entity_color + 2 rows into stock_room ) into a mysql database with a commited query?
I don't think there is a way, but it's worth asking. That's why I want to benefit from your like-mindedness
______________ UPDATE _______________
Unfortunately, some users may irresponsibly and without understanding the question saysaid that this question is repetitiverepeated, so I musthave to point out thatthis point:
if we ignore the third table, this is a solution
START TRANSACTION;
INSERT INTO `entity` (`name`) VALUES (`x`);
INSERT INTO `entity_color` (`entID`,`color`) VALUES (last_insert_id(),'blue'),(last_insert_id(),'red');
COMMIT;
but i have 3 table, it is not posibble that get two ids from entity_color with last_insert_id()