On Mon, Jun 23, 2003 at 06:37:17PM -0500, Zach wrote: > > I am writing a shell script using Born Shell. I am trying to get the result of a SQL > statement into a variable.
You mean Bourne shell. > For example: > > /usr/bin/mysql -uroot -prootpass BOB << EOF > SELECT * FROM Bobstable WHERE Name=1 > EOF > > How do I get the result into a variable? If you plan to add "LIMIT 1" to your query, consider putting the command line into backquotes. Otherwise, use something like: -------- 8< cut here 8< -------- #!/bin/sh mydb="BOB" myuser="user" mypass="p4s$w0rd" #mysql="/usr/local/bin/mysql" mysql="/usr/bin/mysql" q="SELECT this,that FROM Bobstable WHERE Name=1" $mysql -u"$myuser" -p"$mypass" -e"$q" "$mydb" | while read this that; do echo "this is $this, that is $that" done -------- 8< cut here 8< -------- -- Paul Chvostek <[EMAIL PROTECTED]> Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]