MySQL Forums
Forum List  »  Newbie

Execute unix command for each row returned by a query
Posted by: Nombre Apellido1 Apellido2
Date: May 03, 2016 05:05AM

Hi guys,

We're preparing an Unix script to be executed once a day.

It has to make a query to a MySql database. The output of the query is as following:

Email Commerce_URL
------ -------------
peter@gmail.com big-shop.com
maria@somewhere.com walmart.us
bob@google.com tradecenter.com


The command for executing the query is as following:
mysql -u USER -p PASSWORD -h MYSQLSERVERNAME -e 'SELECT u.email , v.commerce_url FROM `users` u, `vendors` v WHERE (DATE(u.created) + 0 = DATE(NOW()) - 1 AND u.vendor_id=v.id AND u.vendor_id IS NOT NULL)' database-name


Therefore, for each row returned by the query, it has to send an email to the recipient specified in the Email column and write the link specified in the Commerce_URL column in the body of the email.

I mean something like that:

To: peter@gmail.com
Message:
Hi,
Thanks for registering at our service. You can visit us at big-shop.com

Kind Regards



Can you direct me to create such a script?

Thanks in advance

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.