mysql数据库case when 的用法

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

猜你喜欢

转载自sunny-xhh.iteye.com/blog/2273948