mysql数据库中case when适合多条件查询的情况一般用法包含两种方式:
1.select id,name,
case
when score>=90 then '优秀'
when score<90 and score>=85 then '良好'
when score<85 and score>=60 then '合格'
else '不合格' end as level from student
2 select id,name,
case
when type ='1 ' then '合格'
else '不合格' end as level from student
MySQL CASE WHEN 用法示例
本文介绍了 MySQL 数据库中 CASE WHEN 语句的两种常见使用方法,一种用于多条件判断并返回不同结果,另一种则针对单个条件进行判断。通过具体的学生分数等级评定示例,展示了如何灵活运用 CASE WHEN 实现数据处理。
588

被折叠的 条评论
为什么被折叠?



