Monday, October 5, 2009

import mysql query into csv

When you want to import the results of a query into a csv, you can use the following mysql query.


SELECT a,b,a+b INTO OUTFILE '/tmp/result.text'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;

No comments:

Post a Comment

 
Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 Generic License.