fast way update mysql json key where code example
Example 1: mysql json change key
UPDATE `my_table`
SET `my_col` = JSON_INSERT(
JSON_REMOVE(my_col, '$.oldKeyValue'),
'$.newKeyValue',
JSON_EXTRACT(my_col, '$.oldKeyValue')
);
Example 2: updating json object in mysql database
SET @data = '{
"Person": {
"Name": "Homer",
"Hobbies": ["Eating", "Sleeping"]
}
}';
SELECT JSON_SET(@data, '$.Person.Name', 'Bart', '$.Person.Hobbies[1]', "Mischief") AS 'Result';