MY-SQL query to export data to excel file

I can export the table data to a CSV file, but I cannot export this data to an excel file. Is there any request to export this data to an excel file.

I use this query to export data as a CSV file.

SELECT * INTO OUTFILE 'C:/your-directory/your-filename.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM tableName 

I used this for the excel file after the name of the change file, for example your-filename.xls but adding the extension .xls, but providing data such as csv.

+7
source share
2 answers

You cannot export the result of a query result directly to excel using SELECT INTO ... You can export in CSV format, which can be easily opened by excel, as you have already done, but you cannot export directly in excel format.

+1
source

All Articles