MySQL update the field in one table equals the value of a field in another

Source: Internet
Author: User
Tags mysql update one table

Update a LEFT join C on a.id = C.id set a.body = C.C1 where a.id=c.id;
Update Zcat as Z left join zcat_bak_1212 as ZB on z.zcatid = Zb.zcatid set z.zcatname = zb.zcatname where Z.zcatname is Nu ll

I used the following
Update Z_vnetid__money a LEFT join Tab_feeaccount b on a.c_vnetid = B.c_accountcode set a.i_id = b.i_id where A.c_vnetid = B.c_accountcode;

1. The table structure is exactly the same
Insert INTO Table 1
SELECT * FROM Table 2
2. The table structure is different (in this case you have to specify the column name)
Insert INTO table 1 (column name 1, column name 2, column name 3)
Select column 1, column 2, column 3 from table 2
3. Take partial values from another table only
Insert INTO table 1 (column name 1, column name 2, column name 3) VALUES (column 1, column 2, (select column 3 from table 2));

MySQL update the field in one table equals the value of a field in another

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.