MySQL case when ... then ...end
我们再开发的时候经常会遇到这种情况,想在数据库层面实现一些逻辑运算,譬如: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),本次博主就更新到此,后面会继续更新。未完待续。。。(欢迎小伙伴们留言,点赞)
-----------你学习的样子真帅(美)