SQL resultset to CSV

Question: I want to grab data from SQL database and show it in csv file.

Answer:

SELECT * INTO OUTFILE '/tmp/out.csv'  
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
    FROM myTable;

More: MySQL manual
Credit: nyem at lowyat.net


About this entry