Export result of MySQL Query to CSV Format
You can run the following query to output the results of a query to CSV Format :
SELECT order_id,product_name,qty FROM orders INTO OUTFILE '/tmp/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'