user8834780
user8834780

Reputation: 1670

Update multiple column based on condition

I have the following queries:

update a
set dwc=fa.dwc
from b fa
join a mw
on a.fa_state=b.state
where b.dwc=''
;
update a
set dwa=fa.dwa
from b fa
join a mw
on a.fa_state=b.state
where b.dwa=''

I am trying to combine into one- is that possible?

Upvotes: 1

Views: 22

Answers (1)

Mureinik
Mureinik

Reputation: 311998

You can have several column clauses in the set clause. You just need to separate them by a comma (,):

update a
set dwc=fa.dwc, dwa=fa.dwa -- Here!
from b fa
join a mw
on a.fa_state=b.state
where b.dwc=''

Upvotes: 1

Related Questions