On Wed, 12 Feb 2003, Dan Tappin wrote: > Does any one have a suggestion on running a daily / weekly e-mail > notification based on results from a MySQL query? > > I have a table with date sensitive rows. The idea that as rows become > stale (they were created / updated more than a week or month ago) the > owner of the row is sent an e-mail with a summary of the stale items or > even just a link back to a web page for updating. > > The e-mail addresses would come from a related 'user' table. The stale > data table would have the 'user' id in a column for a JOIN statement.
I do something similar using a shell script run by cron. This pipes a query into mysql like this: cat mysql_command.list | mysql -u <user> -p<password> database where the file mysql_command.list is a plain text file containing the query which uses SELECT INTO OUTFILE to dump fields containing membership IDs, names and email addresses of all entries between two dates of a membership database into a CSV file. Then the script continues using sed and cut to create a mail message body and header from the data in this CSV file which can be piped into mail (/bin/mail, /bin/mailx or whatever you have on your system) or even directly into sendmail. It works fine. Andy --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php