计算机网络/计算机科学与应用/系统/运维/开发

MySQL8 空值参与运算:NULL

空值参与运算:NULL

null 不等同于0 '' 'null'


错误写法:空值参与运算,结果一定也为空

SELECT employee_id,salary "月工资",salary * (1+commission_pct) * 12 "年工资"

     FROM employees;


实际解决:引入IFNULL

SELECT employee_id,salary "月工资",salary * (1 + IFNULL(commission_pct,0)) * 12 "年工资"
     FROM employees;



人生建议:不要因为嘴硬而失去重要的东西,清醒,知趣,明得失,知进退。

评论

^