|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
mySQL & sh script
Hopefully a simple question...
How do you get a SQL result into a variable using only shell script? I know how to create one and execute it using variables, but I need to make a SQL call and get the result into a variable. Help?? -JimBob |
|
#2
|
||||
|
||||
|
If you're just getting one field, this will work:
Code:
VAR=`echo "SELECT field FROM table WHERE id = '3';" | mysql -u user -ppassword db_name | tail -1`
__________________
Alex (http://www.alex-greg.com) |
|
#3
|
|||
|
|||
|
I posted an answer to this question in the MySQL forum.
__________________
El éxito consiste en una serie de pequeñas victorias día a día MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Linux Help > mySQL & sh script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|