SQL multi-table updates update

Source: Internet
Author: User

There are two tables: Apply and Applydetails, and the two tables are associated with Applyno.

Apply
Column Name Type
Applyno varchar
Applydate Datetime
State varchar
Applydetails
Column Name Type
Applyno varchar
Idcard varchar
Name varchar
State varchar

1) Update the state value in the table Applyno as "0001" to "1" in Apply and applydetails;

Mysql:

1 UPDATEapply T1, Applydetail T22 SETT1.state='0', T2.state='0'3 WHERET1.applyno=T2.applyno andT1.applyno='0001'  andT2.applyno='0001';

2) Update the state value in the table Idcard as "2120141021003731" to "1" in Apply and applydetails;

Mysql:

1 UPDATE apply T1, Applydetail T2 2 SET t1.state='1', t2.state='1'  3WHERE t1.applyno= and T2.idcard='  2120141021003731';

Note: the above SQL statements are only carried out in MySQL5.5, and SQL Server and Oracle do not know if they can be executed and are being tested.

SQL multi-table updates update

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.