In Postgres 9.3 when a field in a table has a null value the following expression doesn't work:
update table_statatistic set members = members + 1 WHERE user_id = $1;
However when the field has an integer value then this query increments it by 1 without a problem.
The questions are:
you need to use coalesce for checking null values
update table_statatistic set members = coalesce(members, 0) + 1 WHERE user_id = $1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With