真的头痛啊。为此语句,这样记忆最好,如下:
遇到 XXX情况 就 XXX 遇不到就 XXX 结束
case when …… then …… else …… end
实例一:
我们都知道SQL中适用case when then来转化数据库中的信息 比如 select (case sex when 0 then '男' else '女' end) AS sex from studentInfo
SELECT id,number,
(case hblfile when '' then 0 else 1 end) as hblfile,
(case hbltxlfile when '' then 0 else 1 end) as hbltxlfile,
(case mblfile when '' then 0 else 1 end) as mblfile
FROM `file`
where number = '2012050002'
group by hblfile,hbltxlfile,mblfile
(case hblfile when '' then 0 else 1 end) as hblfile,
(case hbltxlfile when '' then 0 else 1 end) as hbltxlfile,
(case mblfile when '' then 0 else 1 end) as mblfile
FROM `file`
where number = '2012050002'
group by hblfile,hbltxlfile,mblfile