Eltomon
Eltomon

Reputation: 364

JOIN in UPDATE sql for DB2

Is there a way to use joins in update statements for DB2?

Google has really let me down.

This is roughly what I'm trying to achieve (... except obviously working ....)

Update gk.WR_VEHICLE_WARRANTY w
         join gk.VGARANT_FRIST_ZUWEIS z
              on z.PK_GARANT_FRIST_ZUWEIS = w.FK_GARANT_FRIST_ZUWEIS
set CURRENT = '1'

where z.GW = '1'
  and z.FK_GBE is null
  and z.INTERN = '0'; 

Upvotes: 1

Views: 115

Answers (1)

Eltomon
Eltomon

Reputation: 364

I solved the problem , just took out the join and did a inner select

Update gk.WR_VEHICLE_WARRANTY 
set CURRENT = '1'
Where FK_GARANT_FRIST_ZUWEIS in 
(select PK_GARANT_FRIST_ZUWEIS from gk.VGARANT_FRIST_ZUWEIS z
where z.GW = '1'
  and z.FK_GBE is null
  and z.INTERN = '0' ) 

Upvotes: 1

Related Questions