Export Query Data to CSV with MySQL
Posted on : 06-10-2010 | By : Michael Fitchett | In : MySQL
0
There are multiple ways to export the data from a MySQL Query. I am going to start with the easiest first.
MySQL Query Browser
This is by far the simplest way to export the data that you just queried.
1) Open MySQL Query Browser
2) Write your Query and Run it
3) Right-Click on the Results
4) Click Export Resultset
5) and Click Export As CSV File…
6) Select a location and click save
SQL Query
With this approach you can do it all from within the Query.
SELECT *
INTO OUTFILE 'C:/your-directory/your-filename.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM tableName
You need to make sure that MySQL has read/write access to the directory specified in the query.










