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;
更多的可以参考http://www.cnblogs.com/tillere007/archive/2010/05/25/1743210.html
mysql中的case语句
猜你喜欢
转载自jackyrong.iteye.com/blog/1995615
今日推荐
周排行