在oracle中可以看到decode函数,使用方法如下:
decode(条件,值1,翻译值1,值2,翻译值2,...值n,翻译值n,缺省值)的理解如下:
if (条件==值1)
then
return(翻译值1)
elsif (条件==值2)
then
return(翻译值2)
......
elsif (条件==值n)
then
return(翻译值n)
else
return(缺省值)
end if
而在mysql中用到case when来替代decode
case 条件
when 值1 then 翻译值1
when 值2 then 翻译值2
when 值3 then 翻译值3
else other end