美文网首页
mysql case when

mysql case when

作者: Rinaloving | 来源:发表于2023-02-21 10:57 被阅读0次

case when

1. 语法

  • 简单函数
CASE [col_name] WHEN [value1] THEN [result1]…ELSE [default] END
  • 搜索函数
CASE WHEN [expr] THEN [result1]…ELSE [default] END

2. 举例

  • 例子
select nType,count(nType) as nCount,case nType when 1 then '图书' when 2 then '听书'when 3 then '视频' when 4 then '期刊' when 5 then '图片' when 6 then '精选' end as sBookType from TbCompanyBooks group by nType

QQ截图20230222105631.png

相关文章

网友评论

      本文标题:mysql case when

      本文链接:https://www.haomeiwen.com/subject/qkbnkdtx.html