开发者

MYSQL: How dump resultset into a LONGTEXT variable rather than to a output file

开发者 https://www.devze.com 2023-02-06 22:29 出处:网络
I want to modify the following code: SELECT * INTO OUTFILE \'C:\\\\my_excel_table.csv\' FIELDS TERMINATED BY \',\' OPTIONALLY ENCLOSED BY \'\"\'

I want to modify the following code:

SELECT * INTO OUTFILE 'C:\\my_excel_table.csv'
 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 LINES TERMINATED BY '\r\n'
 FROM m开发者_运维技巧ytable;

so that it dumps the result into longtext/variable rather than to a output file.


Not sure if you can, but there is the INSERT ... SELECT FROM syntax, which lets you insert the results of a select into another table. Problem is that SELECT is going to return rows, which would be inserted one-by-one into the other table, instead of going in as a single long chunk of text.


use insert select

INSERT INTO mytable (my_field) select my_other_field from my_other_table
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号