开发者

How to update multiple tables with one SQL statement in DB2

开发者 https://www.devze.com 2023-01-17 09:50 出处:网络
Pseudo-code as follows: update TABLEA a, TABLEB b set a.addr = \'aaa\', b.name = \'bbb\' from TABLEA a, TABLEB b

Pseudo-code as follows:

update TABLEA a, TABLEB b
set a.addr = 'aaa',
b.name = 'bbb'
from TABLEA a, TABLEB b
where 开发者_运维问答a.id = b.id and a.id = 1


You can only UPDATE one table. So, you can change your SQL to the following:

UPDATE tableA a
SET a.addr = 'aaa'
WHERE exists
     (SELECT b.id
      FROM tableB b
      WHERE b.id = a.id)
0

精彩评论

暂无评论...
验证码 换一张
取 消