How does phpMyAdmin make the number in one table equal to the sum of the three numbers in the other table and can be dynamically updated? I made a recipe information table a, which contains the recipe price. the recipe price consists of three different ingredients, the prices of these three ingredients are included in the total price list B for all ingredients in the other one.
How can I use phpmyadmin to make the recipe price equal to the sum of the prices of the three ingredients in the other table B? How can we establish this connection?
The younger brother is not very familiar with the php language. the problem may be simple. please kindly help me. The details are the best. thank you very much.
I want to update the prices of all recipes containing this ingredient whenever I update the price of one of the ingredients in Table B.
Reply to discussion (solution)
You can create a trigger.
I think the SQL statement can be used to associate two tables.
It depends on what your table looks like.
It is better to create another view.
It depends on what your table looks like.
It is better to create another view.
For example, there is a recipe table where the price of a recipe is made up of beef (10 yuan) garlic (2 yuan) ginger (1 yuan, the total price is 10 + 2 + 1 = 13 yuan. The 13 yuan is associated with the price of beef, garlic, and ginger on the ingredients table, can affect the recipe table composed of these ingredients. When there are many recipes and ingredients, how can we make it easier?