1、case简单写法
case type
when ‘1’ then ‘小超市’
when ‘2’ then '大商场’
else ‘其他’ end
2、–case搜索函数 (需要判断)
case when type = ‘1’ then ‘小超市’
when type= ‘2’ then ‘大商场’
else ‘其他’ end type (可以不写else,不过end 后面加上需要显示的标题)
3、 case简单写法和case搜索函数区别:
第一种case后面直接跟字段,第二种先判断,最后end后面跟字段,或者别名
MySQL之case when then用法
最新推荐文章于 2024-05-06 23:01:53 发布