讨教如下sql实现

MySql 码拜 8年前 (2016-02-10) 803次浏览
— 表结构
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

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明讨教如下sql实现
喜欢 (0)
[1034331897@qq.com]
分享 (0)