美文网首页
case when then else end

case when then else end

作者: zhangxu0636 | 来源:发表于2016-08-22 10:55 被阅读40次
--简单Case函数 
CASE sex
WHEN '1' THEN '男' 
WHEN '2' THEN '女' 
ELSE '其他' 
END 
--Case搜索函数 
CASE
WHEN sex = '1' THEN '男' 
WHEN sex = '2' THEN '女' 
ELSE '其他' 
END 

update tableName set cnt = (case when rcnt >=1 then rcnt -1 else 0 end)

这个时候会先进行case when 求值,表达式求值完以后在进行更新。

相关文章

网友评论

      本文标题:case when then else end

      本文链接:https://www.haomeiwen.com/subject/iztesttx.html