zoukankan      html  css  js  c++  java
  • case when xxx then xxx when xxx then xxx ... else xxx end

    mysql查询语句中的条件判断 case when then else end

    1 若是真假判断

    select case gender when 1 then '男' when 0 then '女' else '未知' end from tt

    2 若是范围划分判断

    select case
    when score < 60 then '不及格'
    when score < 90 then '中等'
    when score >= 90 then '优秀'
    else xxx
    end
    from t1

    或者

    select case
    when play_times < 100 then '少'
    when play_times > 500 and play_times < 1000 then '有点多了'
    when play_times < 3000 then '中'
    when play_times < 5000 then '多'
    else '火爆'
    end as '视频播放次数'
    from video;

  • 相关阅读:
    数组
    JavaScript语法
    Math.random()
    第二第三周暑期集训总结
    第一周
    ACM课程学习总结
    专题四---总结
    专题四--1004
    专题四--1005
    专题四--1006
  • 原文地址:https://www.cnblogs.com/mydesky2012/p/15803269.html
Copyright © 2011-2022 走看看