SQL语句怎么写:当一个表的两个字段都不为空,将其中一个字段改为一个值。

2024-12-01 06:58:50
推荐回答(3个)
回答1:

update tble
set t1=值,t2=值
from not t1 is null and not t2 is null

回答2:

update tableA
set column1=case when column2 is not null then column2 else column1 end,
column2=
case when column1 is not null then column1 else column2 end
where column1 is not null or column2 is not null

回答3:

update tb
set col1=col2
where col1 is not null and col2 is not null