在数据表更新时,可能会出现一种情况,就是更新的内容是来源于其他表的,这个时候,update语句中就加了from,下面为一个范例:

update a set a.name=b.name,a.value=b.value from table1 a,table2 b where b.id='id2' and a.id=b.id

那么就出现一个问题了,如果同时更新两张表,可以实现吗?

比如下面的语句:

update a,c set a.name=b.name,a.value=b.value,c.value=b.value from table1 a,table2 b,table3 c where b.id='id2' and a.id=b.id and a.id=c.id

我尝试的结果是,不可以两张表同时更新,只能一张表一张表的更新(即上面的语句应该拆分成两条,分别执行)。

相关文章:

  • 2021-07-23
  • 2022-12-23
  • 2021-09-24
  • 2021-09-01
  • 2022-02-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
相关资源
相似解决方案