17,377
社区成员
发帖
与我相关
我的任务
分享
SQL> select * from t1;
A B
---------- ----------
1 1
2 1
3 1
4 1
5 1
6 1
6 rows selected
SQL> select * from t2;
A B
---------- ----------
1 0
2 0
3 0
4 0
SQL> update t1 set
2 b=(select b from t2 where t1.a=t2.a)
3 where exists (select 1 from t2 where t1.a=t2.a);
4 rows updated
SQL> select * from t1;
A B
---------- ----------
1 0
2 0
3 0
4 0
5 1
6 1
6 rows selected
SQL>
update aaa t1
set t1.b = (select t2.b from bbb t2 where t1.a=t2.a)
where exists (select 1 from bbb where a=t1.a)