On Sun, 30 Jan 2005, Andy wrote:
> Hi all
>
> I just wanted to know what would be the easiest way to retrieve simple data
> from a MySQL database from a bash script.
I do this a lot - just construct the query and dump it into a file from
within the script, eg:
echo "select * from widgets where colour = 'red';" > /tmp/query
Then pipe the query into the mysql command line client and the result is
echoed to stdin:
$RESULT=`mysql -u user -ppassword widget_sales < /tmp/query`
and the variable $RESULT contains the result of your query.
Andy
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]