I know how to export multiple columns to a csv file. using:
SELECT `col1`, `col2`
FROM table
INTO OUTFILE 'C:/filename.csv'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n';
When I open the file using excel, everything is fine, each record is in a line. But, when I open it using notepad, I find all records are printed next to each other without line separator. How can I make the output of the query to be printed as one record per line and each column separated by comma ??
\nis a line break under linux, but windows uses\r\nAccordingly, this code does what you want
Many other tools like Excel, Notepad++ or WordPad can read file both with
\nand\r\n, so they are not affected by this change and display the file correctly both with your original code and this modification.