I need to update the cumulative sales of all the clients in the accumPurchases field, for which I try to add all the invoices of each one and record this value there
UPDATE contacts
SET
accumPurchases = (SELECT
SUM(inv_total) AS sum_of_inv_total
FROM
invoice_master
WHERE
invoice_master.inv_cntId = contacts.cnt_id)
but I can not get it to work ...
Error Code: 1048. Column 'accumPurchases' cannot be null
Thanks for your guidance.