user-avatar
Today is Thursday
May 16, 2024

October 6, 2009

import mysql query into csv

by viggy — Categories: Uncategorized — Tags: , , , Leave a comment

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;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>