SQL Update多表联合更新的方法

有些时候我们需要同时更新多个表中的数据那么就需要用到下面方法了:

(1) sqlite 多表更新方法

复制代码 代码如下:
//———————————-
update t1 set col1=t2.col1
from table1 t1
inner join table2 t2 on t1.col2=t2.col2

这是一个非常简单的批量更新语句 在SqlServer中支持此语法 sqlite中却不支持

sqlite中可转换为 如下语法

复制代码 代码如下:
update table1 set col1=(select col1 from table2 where col2=table1.col2)

update ta_jbnt_tzhd_pht_Area_xiang set t1=(select sys_xzqhdm.name from sys_xzqhdm
 where t2=sys_xzqhdm.code)

原创文章,作者:kirin,如若转载,请注明出处:https://blog.ytso.com/tech/database/236693.html

(0)
上一篇 2022年1月24日 22:29
下一篇 2022年1月24日 22:29

相关推荐

发表回复

登录后才能评论