MySQL>为INTO OUTFILE的结果添加额外的字符

时间:2015-01-05 20:12:01

标签: mysql sql json function

对不起标题,想不到更好。

所以我的目标是将mysql中的json格式文本直接写入文件。我尝试过几个方法:

1)https://github.com/mysqludf/lib_mysqludf_json - 使用json_array函数

2)使用sql:

SELECT * INTO OUTFILE 'pathToFile' 
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
LINES 
    STARTING BY '['
    TERMINATED BY '],\n'
FROM Table

但两种情况都没有给我我想要的东西。

需要:

[
   ["1","2","3"],
   ["1","2","3"]
]

来自json_array函数:

["1","2","3"]
["1","2","3"]

来自sql:

["1","2","3"],
["1","2","3"],

任何想法如何更改sql语句以获得我想要的结果?或者可能以其他方式实现结果?

0 个答案:

没有答案