we have table with JSON column
for example simple:
{"a": 1}
{"b": 2}
run JSON_MERGE query
select JSON_MERGE('{"a": 1}','{"b": 2}')
result correct:
{"a": 1, "b": 2}
run the GROUP_CONCAT query
select GROUP_CONCAT('\'',json_text,'\'') from t_json
result
'{"a": 1}','{"b": 2}'
but if try to combine both of them:
SELECT JSON_MERGE((select GROUP_CONCAT('\'',json_text,'\'') from t_json))
return error:
Incorrect parameter count in the call to native function 'JSON_MERGE'
any ways for merge JSON documents from group operation?
Best Answer
Assemble desired JSON using string functions and then cast it into JSON.
Example data
Query to merge all
itemProperties
togetherResulting JSON
Several caveats:
JSON_MERGE()
, for example:{}
. This might change in future versions of the server.