I want to give the user the choice to 'overwrite' values in a field in a table or 'add' to the value in the table. The problem is that sometimes the field in the table is null so if the user chooses to 'add' then nothing is updated because mysql is adding null to 10 for instance
I then tried to use the 'IF' statement to detect if the field in the table is null so I can do straight update and if not then I add the new value to the value already in the table.
Query:
UPDATE
table1
INNER JOIN
table2
ON table1.ID = table2.Table1ID
SET
table1.column =
(
IF table1.column = NULL
THEN
table2.column
ELSE
table1.column + table2.column
)
I have an error that says there is a problem with my sql statement. I have tried using 'IS NULL' instead of '= NULL' but it doesn't work either