UPDATE两个表关联更新

update table1 a set a.c  =  (select  b.b from table2  b where a.a=b.a)

另外,如果在a.a=b.a的情况下,如果b.b有多个值的话也会报错

这个时候,可以考虑用b.b的最大值或最小值

update table1 a set a.c  =  (select  max(b.b) from table2  b where a.a=b.a)

猜你喜欢

转载自blog.csdn.net/c851204293/article/details/108776310