Here is what I have, the two columns to be added can be NULL by default:
UPDATE house SET TOTALTAX=IFNULL(MUNTAX,0)+IFNULL(SCHTAX,0) WHERE NNS_NO=542
This gives me 0 rows affected. I verified the NNS number is correct, I don’t really know what to try next.
Okay, I found out the columns MUNTAX AND SCHTAX are type varchar and not integers. For example, MUNTAX = “$7,725.00”, SCHTAX = NULL in this case.
So the question is now how to extract just the dollar value as an integer before calculating the sum and updating it as varchar (TOTALTAX is also varchar)? Do I need a stored procedure?
Edit: Ah I see you also want to turn the result back into a VARCHAR. Adding the $ sign back to the front should be easy with CONCAT(), but adding the commas back in would be tricky without writing a custom function. I probably don’t need to tell you, but storing values like this as VARCHARs in the database isn’t a good idea.
It ain’t pretty, but something like this?