mysql 字符替换问题
按照“性别、学号、姓名、年龄、院系”的顺序列出学生信息,其中性别按以下规定显示:性别为男显示为男 生,性别为女显示为女 生,其他显示为“条件不明”;
——解决方案——————–
case when
——解决方案——————–
select name,(case when sex=’男’ then ‘男生’ when sex=’女’ then ‘女生’ else ‘条件不明’)
from use
——解决方案——————–
select case 性别 when ‘男’ then ‘男生’ when ‘女’ then ‘女生’ else ‘性别不明’ end,学号,姓名,年龄,院系 from table
——解决方案——————–
select case 性别 when ‘男’ then ‘男生’ when ‘女’ then ‘女生’ else ‘性别不明’ end sex,学号,姓名,年龄,院系 from table
加个字段别名