转载
我自己的思路如下:写出来如下,但是如果b中不存在a中的id,psw将会覆盖成null
1. update A set pwd = (select password from B where userid = A.id);
where id in (select userid from B);
参考别人的写法
2. 如果B表的userid为主键的话,,可以使用关联更新..
update (
select a.pwd pwd,b.password
from A,B
where a.id = b.userid
)
set pwd = password;
摘录
oracle:大概这样:
update A set b = (select B.b from B where A.a = B.a)
where A.a in (select B.a from B)
本文探讨了两种SQL表更新的方法:一种是在A表中更新密码字段为B表中对应的password值,但当B表中不存在A表中的id时,密码会被设置为null;另一种是通过表关联进行更新,适用于B表的userid作为主键的情况。
251

被折叠的 条评论
为什么被折叠?



