1。
select name,
case
when birthday<'1981' then 'old'
when birthday>'1988' then 'yong'
else 'ok' END YORN
from lee;
2。
select NAME,
case name
when 'sam' then 'yong'
when 'lee' then 'handsome'
else 'good' end
from lee;
当然了case when语句还可以复合
3。
select name,birthday,
case
when birthday>'1983' then 'yong'
when name='lee' then 'handsome'
else 'just so so ' end
from lee;
mysql中的case语句
原创mb646713a07a071 ©著作权
©著作权归作者所有:来自51CTO博客作者mb646713a07a071的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Mysql中的条件语句if、case
Mysql中的条件语句在我们对数据进行转换的时候比较有用,这样就不需要创建中转表。
mysql if case 条件语句 数据 -
MySQL的if,case语句
Mysql的if既可以作为表达式用,也可在存储过程
mysql 存储过程 返回结果