I have created two tables in mysql for one of the project similar to e-commerce website. One table for transaction progress and other for the details for each transaction status. So, While updating the particular transaction..I should be able to insert rows in to two tables. I know we can insert it by querying separately. I am curious, if there is a way other than this..
Asked
Active
Viewed 48 times
0
-
https://stackoverflow.com/questions/5178697/mysql-insert-into-multiple-tables-database-normalization Please check this url, it has your answer. – Kunal Nov 06 '18 at 06:07
-
https://stackoverflow.com/questions/5178697/mysql-insert-into-multiple-tables-database-normalization Please check this url, it has your answer. – Kunal Nov 06 '18 at 06:07
-
You can use Triggers. Ref: https://dev.mysql.com/doc/refman/8.0/en/trigger-syntax.html – Madhur Bhaiya Nov 06 '18 at 06:13
1 Answers
0
If you join the two tables and create a view you can achieve updating two tables with a single query. This would allow you to perform an insert operation on the view, you will just have to set up triggers for “on insert” of the view to handle inserting into the appropriate tables.
I have done this with MS Sql and Postgres but the same functionality should exist is MySQL.

kbrendle
- 1