Mysql的switch语句

select case status when 1 then '成功' when 2 then '失败' else '其他' end from user

 

  • case后面紧跟要被作为判断的字段
  • when后面跟判断条件
  • then后面跟结果
  • else相当于default
  • end是语句结束语

 

来源:https://blog.csdn.net/u012150370/article/details/50505408

 

posted @ 2020-02-18 16:23  嗝屁的博客  阅读(1312)  评论(0)    收藏  举报