phpMyAdmin How to make the number in one table equal to the sum of three numbers in the other table and update dynamically?

Source: Internet
Author: User
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?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.