Implementation Code of SQL update multi-table join update, sqlupdate

Source: Internet
Author: User

Implementation Code of SQL update multi-table join update, sqlupdate

Update multiple tables, especially the data in Table A and Table B of table A. The following is an example.

There are tables A and B with the following records:

Table

C1 c2
--------------
1 a1
2 a2
3 a3
8 a8

Table B

C1 c3
--------------
1 b1
2 b1
3 b3
10 b10

A. c1 is equal to B. c1. Use an SQL statement to update the value of A. c2 to B. c3.
Bytes ---------------------------------------------------------------------------------------

Statement 1

UPDATE A SET A.c2 =B.c3from A ,Bwhere A.c1=B.c1

Statement 2

UPDATE  ASET A.c2 =B.c3from A inner join B on A.c1=B.c1

Note:

The update clause cannot be followed by multiple tables, but is followed by the from clause.

Summary

The above is the implementation code of SQL update multi-Table Association update introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

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.