Question: I'm having this json stored in db

```
{
    "endDate": "2018-10-10",
    "startDate": "2017-09-05", 
    "oldKeyValue": {
        "foo": 1000, 
        "bar": 2000, 
        "baz": 3000
    },
    "anotherValue": 0
}

```

How can I rename `"oldKeyValue"` key to `"newKeyValue"` without knowing the index of the key in an `UPDATE` query? I'm looking for something like this

```
UPDATE `my_table` SET `my_col` = JSON()

```

NOTE: only the key needs to change, the values (i.e. `{"foo": 1000, "bar": 2000, "baz": 3000}`) should remain the same

Answer: 
I personally prefer another method:

```
UPDATE my_table SET my_col = REPLACE(my_col, '"oldKeyValue":', '"newKeyValue":')

```

This replaces directly the key name in the JSON string without destroying the JSON structure.

I am using the additional `:` in order to avoid an unintentional replacement in a value.
Plain text search & replace will only work if the JSON is stored in minified/compact format without extra whitespace in it.