Mysql compared to the problem of updating another table with multiple conditions

Source: Internet
Author: User
Mysql compared to the problem of updating another table with multiple conditions A B C three tables

Data Table
B sets the BID B1 B2 B3 fields for the condition.
C is the cid uid field of the user table.

Table A meets the three conditions A1 A2 A3. these three conditions are the conditions for collecting user data.
Then, according to the UID value updated by the CID in Table C

In fact, the BID value that meets the three conditions is updated to the CID of table C.

Conditions set in Table B
BID = 1 B1 = 10 b2= 100 B3 = 180
BID = 2 B1 = 30 b2= 150 B3 = 200
BID = 3 B1 = 50 b2= 180 B3 = 230

Compare the three statistical conditions $ A1 $ A2 $ A3> = B1 B2 B3 value in Table B, and update the BID value of the corresponding condition to CID in Table C.

How can I do this? But the CID of table C is equal to only one value of Table B's BID.

My current practice is to use two SQL statements, one is to query the BID that meets the condition, and the other is to update the BID that meets the condition to C.
Is there a way to complete a mysql statement?


Reply to discussion (solution)

You only have two associated fields for the three tables. you just need to check them according to the conditions. The most important thing is to have associated fields.

Currently, only two statements are completed, and association is unlikely.

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.