mysql判断字段为零,返回空字符串

很着急、意思就是
如果 查询一个值,如果为0,就返回一个“”空字符串。

select paymentno,amount,
 case 
     when amount>0 and amount<=40 then 'low'
        when amount>40 and amount<=80 then 'moderate'
        when amount>80 then 'high'
        else 'incorrect' end lvl
from `penalties`

.#对罚款登记分为三类,第一类low,包括大于0小于等于40的罚款,第二类moderate大于40
 #到80之间的罚款,第三类high包含所有大于80的罚款。


同理查询是否为0 也可用 case when , 

select   ***   case when ***=0 then ''  else '***' end lvl form ****

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答