when 值3 then 值4 --当列的值等于值3 就返回值4
end
case when 列=值1 then 值2 --当列的值等于值1 就返回值2
when 列=值3 then值4 --当列的值等于值3 就返回值4
end
if 作为条件判断,一般用在存储过程或者函数里面;譬如
if sqlstate ='02000' then
select xxx from tab
case是作为判断,用在查询当中
select id, case when id = 1 then 'one' else 'null' end
高效两个没有可比性,深究一点,都是一个逻辑判断,然后出结果,所以旗鼓相当,没必要在这个问题上探究性能问题
switch (i){case 0:
CaseZero()
break
case 1:
CaseOne()
break
case 2:
default//单词错了
CaseTwo()
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)