techfolks mysql tutorials
Mysql Tips&Tricks

How to Get MySql Query Result as an Email


If you are working on a big mysql query and want to get the mysql query as email when it finishes use the below trick.

Go to mysql command:
Set pager directive:

mysql> pager mail -s “subject” emailme@domain.com
PAGER set to ‘mail’ -s “subject” emailme@domain.com

The trick uses pager directive to redirect the query output result to a mail program rather than displaying on mysql command.

Once above step is done, change database and run your query the query result will be emailed to the given email id