Update SQL statements with One-to-multiple table fields

Source: Internet
Author: User


One-to-multiple table Field update SQL statement table T_A www.2cto.com id name1 Zhang weisan 2 LITH table T_ B id name1 zhangs1 zsan1 zs2 lisi2 ls www.2cto.com objective: change the name of the record corresponding to the id in Table T_ B and the id in Table T_A to be consistent with the name in Table T_A. As follows: id name1 Zhang San 1 Zhang San 1 Zhang San 2 Li Si 2 Li Si Execute SQL: UPDATE T_ B SET (NAME, ID) = (select name, id from (SELECT T_ B .ROWID RD, T_A.NAME, t_A.ID FROM T_A, T_ B WHERE T_A.ID = T_ B .ID) tmp where T_ B .ROWID = TMP. RD );

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.