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?

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

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.