MySql field values to update a table to another table

statement:

Filled into another table where some fields in the fields table syntax using two different configurations of a table

sql statement

update table1 a1,table2 a2  
set a1.要填充字段=a2.对应索取字段
where a1.id=a2.id
#必须保证有对应字段写在where之后  可以正常添加筛选条件

Example:

update sem_creative_type_sogou a1,sem_adgroup_type_sogou a2  
set a1.campaign_name=a2.campaign_name,
a1.campaign_city=a2.campaign_city,
a1.adgroup_name=a2.adgroup_name
where a1.adgroup_id=a2.adgroup_id  AND a1.campaign_name is NULL

result:

 

thanks for watching

Guess you like

Origin blog.csdn.net/Alice_qixin/article/details/88176960