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;