Mysql updates another table through one table, and mysql updates another table

Source: Internet
Author: User

Mysql updates another table through one table, and mysql updates another table
 

In mysql, you can modify the content of another associated table through the columns of one table:

1: Modify 1 column

Update student s, city c set s. city_name = c. name where s. city_code = c. code;

 

2: Modify multiple columns

Update a, B set a. title = B. title, a. name = B. namewhere a. id = B. id

 

3: subquery

Update student s set city_name = (select name from city where code = s. city_code );

 

REF:

Http://dba.stackexchange.com/questions/119621/how-to-update-10-million-rows-in-mysql-single-table-as-fast-as-possible

Http://stackoverflow.com/questions/6393763/fast-cross-table-update-with-mysql

Http://stackoverflow.com/questions/11709043/mysql-update-column-with-value-from-another-table

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.