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..
-
stackoverflow.com/questions/5178697/… Please check this url, it has your answer.Kunal– Kunal2018-11-06 06:07:39 +00:00Commented Nov 6, 2018 at 6:07
-
stackoverflow.com/questions/5178697/… Please check this url, it has your answer.Kunal– Kunal2018-11-06 06:07:57 +00:00Commented Nov 6, 2018 at 6:07
-
You can use Triggers. Ref: dev.mysql.com/doc/refman/8.0/en/trigger-syntax.htmlMadhur Bhaiya– Madhur Bhaiya2018-11-06 06:13:27 +00:00Commented Nov 6, 2018 at 6:13
Add a comment
|
1 Answer
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.