Field Value of Table A updated to table B

Source: Internet
Author: User

Table A field updated to table B field value T1 table structure id name school1 ming1 Tsinghua University 2 ming2 Peking University 3 ming3 Fudan University T2 table structure id student school11 ming1 Oxford University 12 ming3 Cambridge University the name of table T1 corresponds to the student value of table T2 on a 1-to-1 basis. Requirement: the values of these two fields are the same, and the school of Table A is updated based on the school of Table B. Statement: update t1 set school = (select school from t2 where name = student) where exists (select * from t2 as B where name = B. student); Result: T1 table structure id name school1 ming1 Oxford University 2 ming2 Peking University 3 ming3 Cambridge University Note: Do not add the table to be updated in the condition. PS: join query statement: select aii. update_time, pn. public_time, pn. * from t_apply_item_instance aii, t_public_notice pn where pn. apply_item_instance_uuid = aii. uuid and aii. apply_item_uuid in ('000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000 ', '123', '123', '123') and aii. apply_status = 21 and pn. public_type = 1 update statement: update t_public_notice set public_time = (select aii. update_time from t_apply_item_instance aii where apply_item_instance_uuid = aii. uuid and aii. apply_item_uuid in ('000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000 ', '123', '123', '123') and aii. apply_status = 21 and public_type = 1) where exists (select t1. * from t_apply_item_instance as t1 where region = t1.uuid and t1.apply _ item_uuid in ('2016', '2016', '2016 ', '123', '123', '123', '123', '123', '123', '123', '123', '123 ') and t1.apply _ status = 21 and public_type = 1) the update table does not exist in the following conditions.

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.