update table_a a INNER JOIN table_b b on a.id = b.id set a.xxx = b.xxx;
table_a 代表着需要更新的表。
table_b 代表着你查询出来的表,也可以是你数据库中存在的表。
on 后面的是 table_a和table_b的关联条件。
set 后面的是需要设置的字段值。
table_b 也可以是这样......
(select * from table_c left join table_d ... ... )总而言之也可以是个查询的结果集,那么上面的SQL语句就写成如下形式。
update table_a a INNER JOIN (select id,xxx,xxx,xxx from table_c left join table_d ... ... on table_c.xxx = table_d.xxx ) b on a.id = b.id set a.xxx = b.xxx;