导出一个Mysql查询的结果为excel? [英] Exporting results of a Mysql query to excel?
本文介绍了导出一个Mysql查询的结果为excel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的要求是存储查询的整个结果
My requirement is to store the entire results of the query
SELECT * FROM document
WHERE documentid IN (SELECT * FROM TaskResult WHERE taskResult = 2429)
到Excel文件。
推荐答案
实现此目的的典型方法是导出到CSV,然后将CSV加载到Excel中。
您可以使用任何MySQL命令通过在 SELECT
语句中包含 INTO OUTFILE
子句来执行此操作:
The typical way to achieve this is to export to CSV and then load the CSV into Excel.
You can using any MySQL command line tool to do this by including the INTO OUTFILE
clause on your SELECT
statement:
SELECT ... FROM ... WHERE ...
INTO OUTFILE 'file.csv'
FIELDS TERMINATED BY ','
请参阅此链接详细选项。
或者,您可以使用mysqldump将转储存储到使用--tab选项分隔值格式,请参阅此链接
Alternatively, you can use mysqldump to store dump into a separated value format using the --tab option, see this link.
mysqldump -u<user> -p<password> -h<host> --where=jtaskResult=2429 --tab=<file.csv> <database> TaskResult
这篇关于导出一个Mysql查询的结果为excel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文