The syntax for selecting data from mysql and inserting it into a file is:
select * from table
into outfile ‘/tmp/outfile.csv’ —specify the output file
FIELDS TERMINATED BY ‘,’ —specify the delimiter
ENCLOSED BY ‘”’ —data in quotes?
LINES TERMINATED BY ‘\n’; —specify EOL delimiter
The above is on a linux system, so change the path to C:\ or whatever you want for a windows system