I'm trying the new API for mysql 5.7 which deals with JSON columns. My test column looks like this:
{"foo":{"efg":1}, "bar":{"abc":0}}
What I would like to do is append to one of the keys, for example foo so it will result in "foo":{"efg":1, "klm":2}. What I've tried so far following their documentation:
mysql> select json_insert(test, '$.foo', 10, '$.foo.klm', 2) from table1
where name='Joe';
What that does is replace "efg":1 and the result is "foo":{"klm":2}.
mysql> select json_array_append(test, '$.foo', '{"klm":2}') from table1 where
name="Joe';
The above line obviously converts foo into an array "foo":[{"efg":1}, {"klm":2}], which is not what I want.
I've tried combining queries together:
mysql> select json_insert(test, '$.foo', 10, '$.foo',
select json_merge(select json_extract(test, '$.foo') from table1
where name="Joe"), '{"klm":2}') from table1 where name="Joe";
That just gives me a syntax error near select json_extract(test, '$.foo').
Any advice would be much appreciated.
{"foo":{"efg":1, "klm":2}, "bar":{"abc":0}}. Their documentation mostly works with modifying arrays but I would like to keep everything as an Object.json_insert, (or justselect json_insert(test, '$.foo.klm', 2) from table1 where name='Joe';"efg":1does not disappear for me."foo"Object.select json_merge(test, '{"foo":{"klm":2}}') FROM table1;? Still droppingefg?select json_insert(test, '$.foo.efg', 1, '$.foo.klm', 2) from...