mysql将一张表中的符合条件的字段更新到另一张表中

假如要将B表中的字段更新到A表中

语句:
update 库名.表A
inner join(select 列a,列b from 表B) c
on A.列名 = c.列名
set A.列名 = c.列名;

举例:
update DB.rank inner join(select school_id,ch_name from school) c
on rank.school_name = c.ch_name
set rank.school_id = c.school_id;

你可能感兴趣的:(数据库)