Exporting results of a Mysql query to excel?

后端 未结 5 1562
有刺的猬
有刺的猬 2020-11-29 00:36

My requirement is to store the entire results of the query

SELECT * FROM document 
WHERE documentid IN (SELECT * FROM TaskResult WHERE taskResult = 2429)
         


        
5条回答
  •  孤街浪徒
    2020-11-29 01:06

    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 ','
    

    See this link for detailed options.

    Alternatively, you can use mysqldump to store dump into a separated value format using the --tab option, see this link.

    mysqldump -u -p -h --where=jtaskResult=2429 --tab=  TaskResult
    

提交回复
热议问题