— 表结构
select num, name, name1 from tb;
1 a
2 b
3 c
4 d
需要实现如下结果的sql更新语句:
1 a
2 b a
3 c c
4 d d
select num, name, name1 from tb;
1 a
2 b
3 c
4 d
需要实现如下结果的sql更新语句:
1 a
2 b a
3 c c
4 d d
解决方案
40
update tb
set name1=case name when “a” then null when “b” then a else name end
set name1=case name when “a” then null when “b” then a else name end