Case When Else End用法详解

更新数据

update table  
set 字段1=case     
    when 条件1 then 值1       
    when 条件2 then 值2      
    else 值3      
    end     
where    …… 

查找数据

select 字段1, 字段2,       
    case 字段3     
    when 值1 then 新值       
    when 值2 then 新值      
    end as 重新命名字段3的名字       
from table      
where ……      
order by ……  

猜你喜欢

转载自blog.csdn.net/weixin_43473360/article/details/83786263
今日推荐