I create table TABLE_A with column "product_value" type decimal(11,2) NULLABLE and try update using JSON_TABLE as follow
UPDATE TABLE_A src
JOIN JSON_TABLE("[{\"id\":1,\"product_value\":null}]",'$[*]' COLUMNS
(id int(11) PATH '$.\"id\"',
product_value decimal(11,2) PATH '$.\"product_value\"' NULL ON EMPTY)) as target
ON src.id = target.id
SET
src.product_value = null
where src.id = 1;
I got the error
Invalid JSON value for CAST to DECIMAL from column product_value
Why I cannot set null to column product_value when using JOIN JSON_TABLE?
But I can update this field to NULL by this command:
UPDATE TABLE_A src
JOIN TABLE_B as target ON src.u_id = target.u_id
SET src.product_value = null
WHERE src.id = 1
The result had no error.
Both sql update the SAME column to NULL. But the sql with JSON_TABLE has error. Do you have any suggestion?