单行的:
SELECT JSON_OBJECT(‘id’, sbtest9.id,
‘k’, sbtest9.k,
‘c’, sbtest9.c,
‘pad’, sbtest9.pad) AS josn
FROM sbtest9 limit 10 ;
多行的
SELECT sbtest9.*,
JSON_ARRAYAGG(JSON_OBJECT(‘id’, sbtest9.id,
‘k’, sbtest9.k,
‘c’, sbtest9.c,
‘pad’, sbtest9.pad)) AS JsonArray
FROM sbtest9 group by c;
https://docs.pingcap.com/zh/tidb/stable/json-functions#创建-json-值的函数