MySql 中 case when then else end 的用法

解释:

SELECT            
    case                   -------------如果
    when sex='1' then '' -------------sex='1',则返回值'男'
    when sex='2' then '' -------------sex='2',则返回值'女'  
    else 0                 -------------其他的返回'其他’
    end                    -------------结束
from   sys_user            --------整体理解: 在sys_user表中如果sex='1',则返回值'男'如果sex='2',则返回值'女' 否则返回'其他’
update  user_info 
set 
Emp_responsible_name  = 
    case                             -------------如果
    when Emp_responsible_name ='1212' then '12121212'  -------------Emp_responsible_name=第一个参数  则返回  第二个参数
    else Emp_responsible_name end             -------------否则 则为原值
where emp_code in ('200073','200935')                
原文地址:https://www.cnblogs.com/mytzq/p/8358315.html