I have a table with a json column that looks like this :
+----+------------+
| id | myfield |
+----+------------+
| 1 | ["1", "2"] |
| 2 | ["3", "2"] |
| 3 | ["2", "4"] |
+----+------------+
How can I merge all values from myfield in one array?
I need a result that will look like this: ["1", "2", "3", "2", "2", "4"]
, or even better with removed duplicates.
I tried using this query:
SELECT JSON_ARRAYAGG(myfield) FROM json_test
but as a result I'm getting:
[["1", "2"], ["3", "2"], ["2", "4"]]
I assume I need a query in combination with the function JSON_MERGE.