MySQL case when ... then ...end

一缕粉黛千般容 2019-06-14 11:59:33
我们再开发的时候经常会遇到这种情况,想在数据库层面实现一些逻辑运算,譬如:if else(一种简单的形式,本篇只写一种,select tableName.name,if(tableName.age < 18,'未成年','成年') as tableField from tbaleName where);另外一种类型类似switch case (select tableName.* (case when tableName.age < 18 then '未成年' when tableName.age >=18 then '成年人' end ) as tableField from tableName where... ,这种方式一定要注意,结尾的end),本次博主就更新到此,后面会继续更新。未完待续。。。(欢迎小伙伴们留言,点赞) -----------你学习的样子真帅(美)
...全文
12 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧