English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app

Quick Syntax to Pipe an SQL Query Directly to a file


Here is a quick way to put the contents of a database table into a simple text file. This could be handy if for example, you just want to grab some emails and pop the results into a simple csv file. Your sql statement can be as creative as sql allows. All you are doing here is piping the query to mysql and then saving it to a file.

echo 'select concat(firstname, ', ', lastname, ', ', email) from email_subscribers' \
| mysql -uroot -p emails_database > emails.csv
Tagged w/ #cmd #pipe #sql #tipprogramming