SQL-update的使用

今天工作上遇到了一个问题。如何用一个表的某一列数据去修改另一个表的列。

update 表名 set =where 筛选条件;

这个是update的普通用法。
但是在涉及两个或者多个表时,又该怎么使用呢?
一种较好的用法是使用表连接。

update (table1 inner join table2 on table1.id=table2.id) set table1.col=table2.col where 筛选条件;

即多表关联的结果,Oracle也认为这是一个表。故可以用update进行修改。

发布了23 篇原创文章 · 获赞 8 · 访问量 4134

猜你喜欢

转载自blog.csdn.net/weixin_36522099/article/details/103570528