JSON_OBJECTAGG
Aggregate key-value pairs into a JSON object. This function aggregates two columns or expressions into a single JSON object.
Syntax
JSON_OBJECTAGG(key, value)Description
Examples
SELECT * FROM t1;
+------+-------+
| a | b |
+------+-------+
| 1 | Hello |
| 1 | World |
| 2 | This |
+------+-------+
SELECT JSON_OBJECTAGG(a, b) FROM t1;
+----------------------------------------+
| JSON_OBJECTAGG(a, b) |
+----------------------------------------+
| {"1":"Hello", "1":"World", "2":"This"} |
+----------------------------------------+Last updated
Was this helpful?

