mysql case when

《mysql 官方说明书》

 

 

select 
case when statusCode<=2 then '上海' 
when statusCode>2 then '河南' end write1
,case statusCode 
when '1' then '上海-1'
when '2' then '上海-2'
end write2
from (
select '1' as statusCode,'上海-浦东' as city union all 
select '2' as statusCode,'上海-徐汇' as city union all 
select '3' as statusCode,'河南-郑州' as city union all 
select '4' as statusCode,'河南-开封' as city 
)t

 

posted @ 2020-04-22 16:59  linbo.yang  阅读(656)  评论(0编辑  收藏  举报