mysql更新兩個表使用子查詢的案例

在大陸的javaeye看到的
先抄一下 搞不好以後會看到
table a 要更新兩個欄位 來源是 table b
條件是age>=40.
解法1.

 

update a inner join b on a.id=b.id
set A.column1 =b.column1,a.column2=b.column2
where b.age>40;

解法2.

 

update A,B
set A.column1 = (
select b.column1
from B where B.id = A.id
and B.age > 40
),
A.column2 = (
select b.column2
from B where B.id = A.id
and B.age > 40
) where b.id=a.id and b.age>40;

我想到的是解法2不過看起來解法1.比較簡潔