根据条件更新多列

时间:2018-06-25 19:01:27

标签: sql syntax sql-update amazon-redshift

我有以下查询:

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=''

我试图合并为一个-可能吗?

1 个答案:

答案 0 :(得分:1)

set子句中可以有几个column子句。您只需要用逗号(,)将它们分开:

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=''