Export MySQL data to CSV file using csv filw code example
Example 1: mysql output csv
-- If you are using linux,
SELECT id, filename
FROM attachments
INTO OUTFILE '/tmp/results.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
-- and find the csv file /tmp
Example 2: export mysql table to file
mysqldump db_name tbl_name;