Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: sql查询结果输出json格式
To improve efficiency, please provide the following information. A clear problem description can help resolve the issue faster:
【TiDB Usage Environment】
Big data retrieval
【Overview】 Scenario + Problem Description
Big data uses JSON format data. How can I directly output the SQL execution results in JSON format?
Is the volume large? Navicat directly supports exporting in JSON format.
I want to batch pull data daily in the code and directly convert it to JSON.
Single row:
SELECT JSON_OBJECT('id', sbtest9.id,
'k', sbtest9.k,
'c', sbtest9.c,
'pad', sbtest9.pad) AS json
FROM sbtest9
LIMIT 10;
Multiple rows:
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;
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.