开发者

How to update multiple tables with one SQL statement in DB2

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜