I made a recipe information sheet A, which contains the price of this recipe, which is made up of three different ingredients, and the price of these three ingredients is included in the Total Price table B of all the ingredients in another.
How do I operate in the phpMyAdmin to make the price of the recipe equal to the sum of the three ingredients in the other food table B? How do you get this connection set up?
Little brother to PHP language is not very understand, perhaps the problem is relatively simple, but also help the conscientious, said the details of the best, thank you very much.
I would like to be able to update the price of all the recipes that contain this ingredient whenever the price of one of the ingredients is updated in the food table B.
Reply to discussion (solution)
A trigger can be created.
I think that the use of SQL statements, two-table association query can be implemented
It depends on what your watch looks like.
Building a better view
It depends on what your watch looks like.
Building a better view
For example, there is a cookbook table, one of the recipes is the price of beef (10 yuan) garlic (2 yuan) ginger (1 yuan) composition, the total price is 10+2+1=13 yuan, this 13 yuan linked to the food table on the price of beef, garlic and ginger, any price change of food, can affect the recipe table is composed of these ingredients. In the case of many kinds of recipes and ingredients, how to do the most simple?