Posted by: prajapatinilesh | October 29, 2008

MySql query records into csv or text file

1) Mysql query like:
SELECT order_id,product_name,qty,prize FROM orders_tab

2) Into text file:
SELECT order_id,product_name,qty,prize
FROM orders_tab
INTO OUTFILE '/tmp/orders_file.txt'

3) Into csv file:
SELECT order_id,product_name,qty,prize
FROM orders_tab
INTO OUTFILE '/tmp/orders_file.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

Thanks,
Nilesh.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: