MySQL: query result to file using console

Given a query like below to log the results to a text file


select id from accounts where deleted=1;

try using the command below to output the result to file to ‘C:\test.txt’


select id from accounts where deleted=1 into outfile 'C:\\test.txt';

try using the command below to output the reuslt to csv


select id from accounts where deleted=1 INTO OUTFILE 'C:\\test.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
Advertisements
MySQL: query result to file using console

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