mysql流程控制函数 电脑版发表于:2022/4/27 19:46 **第一种:匹配具体的值** ``` -- case when select username,sex,age,country, case country when '蜀国' then '刘备' when '魏' then '曹操' when '宋' then '赵匡胤' else '其他' end as '领导人' from users ``` **第二种:匹配一个范围条件** ``` -- 显示考试成绩的等级 select username,sub,score, case when score=150 then '满分' when score>=130 then '优秀' when score>=110 then '良好' when score>=90 then '及格' else '不及格' end from score where username = '诸葛亮' ``` 执行结果: 