简单函数CASE [col_name] WHEN [value1] THEN [result1]…ELSE [default] END new_col_name -- 枚举 select t_name, case t_name
简单函数CASE [col_name] WHEN [value1] THEN [result1]…ELSE [default] END new_col_name
-- 枚举
select
t_name,
case t_name
when ‘张三‘
then ‘严肃‘
when ‘李四‘
then ‘凶狠‘
when ‘王五‘
then ‘和蔼‘
end t_character
from `teacher`
搜索函数CASE WHEN [expr] THEN [result1]…ELSE [default] END new_col_name
-- 搜索判断
select
*,
case
when s_score < 60
then ‘不及格‘
when s_score >= 60 and s_score < 80
then ‘中等‘
when s_score >= 80
then ‘优秀‘
end score_type
from `score`
Mysql case when 理解和应用
--结束END--
本文标题: mysql case when 理解和应用
本文链接: https://lsjlt.com/news/7692.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0