I am trying to execute select query and store the result in a variable in shell script. Below is the script
mysql="mysql -h localhost -u root"
db="testdb";
echo "Select Name from Details"|${mysql} ${db};
The above statement gets executed with the column 'Name' getting printed with its value. But when i try to assign the result like below
var = `"Select Name from Details"|${mysql} ${db};`
echo $var
or
var = $("Select Name from Details"|${mysql} ${db};)
echo $var
I get the below error 'var: not found'. Where am i going wrong in trying to assign the result of the query to the variable?