William_He
William_He

Reputation: 357

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

Upvotes: 1

Views: 17007

Answers (1)

Pramendra Gupta
Pramendra Gupta

Reputation: 14873

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)

Upvotes: 4

Related Questions