MySQL to CSV file Jun 14, 2016 • cm SELECT order_id,product_name,qty FROM orders WHERE foo = 'bar' INTO OUTFILE '/tmp/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; TODO : There is still to find how to print the column titles along with the result... Source : http://stackoverflow.com/questions/356578/how-to-output-mysql-query-results-in-csv-format ref : http://www.tech-recipes.com/rx/1475/save-mysql-query-results-into-a-text-or-csv-file/