下面是实例
CREATE TABLE test_user
(
id int primary key auto_increment ,
name varchar(50) not null ,
gender tinyint default 1 ,
country_code smallint
) engine=InnoDb default charset=utf8;insert into test_user(name,gender,country_code) values ('清风',1,100) ;
insert into test_user(name,gender,country_code) values ('玄武',2,100) ;
insert into test_user(name,gender,country_code) values ('Kobe',1,110) ;
insert into test_user(name,gender,country_code) values ('John Snow',1,200) ;select id,name,gender,
(
case gender
when 1 then '男'
when 2 then '女'
else '未知'
end
) 性别,
country_code
from test_user;