집 >데이터 베이스 >MySQL 튜토리얼 >Mysql整数运算NULL值处理注意点_MySQL
CleverCode最近在导出报表的时候,在整数做减法的时候,发现整数减去null得到是null。这是一个细节问题,希望大家以后注意。
select id, total, used, (total - used) as have from test_table
select id, ifnull(total,0) as total, ifnull(used,0) as used, (ifnull(total,0) - ifnull(used,0)) as have from test_table