mysql case else case_value:mysql
casesql
case_value
when ...then ... elsecode
case_value
end ...
it
blobio
使用cast(... as ...)轉換類型,以下:table
select cast(case title ast
when 1 then 'title1' class
when 2 then 'title2' select
else title end stackoverflow
as char(20)) as 'title'
from table;
參考:
http://stackoverflow.com/questions/7830506/mysql-case-enumint-when-varchar-else-int-returning-as-blob-how-to-cast-as-a-va