The correct answer upstairs, but I think from a database perspective, if an attribute needs to be able to be added and subtracted, then the default value should be set to 0 when designing the database, so that there is no need to use it. ifnul function
It works in mysql, and you can find the corresponding function in other DBs:
select
a
+ ifnull(b
, 0) fromfoo
;The correct answer upstairs, but I think from a database perspective, if an attribute needs to be able to be added and subtracted, then the default value should be set to 0 when designing the database, so that there is no need to use it. ifnul function