Monday, January 5, 2009

Exporting MySQL to CSV

For some quick reporting, I needed to export some data from a table into csv format, and this proved to be particularly handy.

SELECT * INTO OUTFILE 'output.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n' FROM users;,11324,11324#msg-11324 contains enough info on both of the common approaches, the other of which uses sed.

No comments: