1、更新一个字段
方法一
update table1 set field1=table2.field1 from table2
where table1.id=table2.id
方法二:将两张表以内连接的方式进行查询更新
UPDATE tableName1 t1
LEFT JOIN tableName2 t2 ON t2.id = t1.id
SET t1.lpEntityType2 = t2.lpEntityType2
方法三
update A m,B mp set m.job_type = mp.job_type where mp.mobile= m.mobile;
2、更新多个字段
方法一
update B, A
set
B.username = A.username,
B.phone = A.phone
where
B.userId = A.userId
方法二:将两张表以内连接的方式进行查询更新
update
B join A on B.userId=A.userId
set
B.username = A.username,
B.phone = A.phone