1、在mysql中,应该使用inner join,即:
update ainner join b
on a.username = b.username
set a.password = b.password
2、在sqlserver中,应该使用update set from 即:
update aset username = b.username
from a, b
where a.userid = b.userid
3、在 oracle 中不存在 update from 结构, 所以遇到需要从另外一 个表来更新本表的值的问题的时候,
有两种解决的办法 :
一种是使用子查询: 使用子查询时一定要注意where 条件 ( 一 般后面接 exists 子句 ) , 除非两个表是一一对应的,
否则 where 条件必不可少,遗漏掉 where 条件时可能会导致插入大量空 值。
另外一种是类视图的更新方法:这也是 oracle 所独有的。先 把对应的数据全部抽取出来,然后更新表一样更新数据,
这 里需要注意的是,必须保证表的数据唯一型。
注意:
oracle中是不支持update:from这样的句子的,mysql和sqlserver是支持的但也有区别。
