write mysql to csv code example
Example 1: mysql export query result to csv
SELECT order_id,product_name,qty
FROM orders
WHERE foo = 'bar'
INTO OUTFILE '/var/lib/mysql-files/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Example 2: export mysql table to file
mysqldump db_name tbl_name;