JSON_SET and JSON_REPLACE
JSON_SET inserts or updates a path. JSON_REPLACE only updates existing paths. JSON_INSERT only inserts new paths.
JSON_SET inserts or updates a path. JSON_REPLACE only updates existing paths. JSON_INSERT only inserts new paths.
UPDATE products
SET attributes = JSON_SET(
attributes,
'$.ram', 32,
'$.gpu', 'RTX 4090'
)
WHERE id = 1;
SELECT attributes FROM products WHERE id = 1;
JSON_SET is the safe default — it does both insert and update.