I have two tables in MySql database, one is sales_order
and the other is sales_order_details
which contains the details of the order in the s
There are 2 ways which you could solve this:
After inserting the entry in the sales_order:
Get the last_insert_id
and store it in a php variable, then inject this value into the relevant queries.
Store the last_insert_id
in a MySql user-defined variable and use the variable in the query instead of last_insert_id
.
SET @last_order_id = last_insert_id();
insert into sales_order_details (order_id, prod_id, prod_price)
values (@last_order_id, 5, 1500);`
insert into sales_invoice (order_id, invoice_id)
values (@last_order_id, 1);`