1、语法
2、举例练习
(1)建表
create table test15(
sname varchar(5),
gender tinyint
)engine myisam charset utf8;
insert into
test15 values
(‘张三’,1),(‘韩梅梅’,0),(‘李宇春’,2);
(2)进行gender的分支控制,1指向男,0指向女,2指向春;
语句:
select sname, case gender when 1 then ‘男’
when 0 then‘女’ else ‘春’ end as xingbie from test15;