Dumping a SQL query into a CSV file in MySQL

Yet another note to myself…

SELECT order_id,product_name,qty 
FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

Credit to http://www.tech-recipes.com/rx/1475/save-mysql-query-results-into-a-text-or-csv-file/

This entry was posted in Technology and tagged . Bookmark the permalink.