I was excited to see how easy it is to write a bash script to interact with MySQL.
But trying this:
#!/bin/bash
res=`mysql -u $USER -p$PASS students <<EOF | tail -n +2
SELECT name FROM table WHERE age = 20 limit 1;
EOF`
for d in $res;
do
echo Result : $d
done
If the result is "John Smith" I get:
Result: John
Result: Smith
How can I get around this issue with the space?
It seems like it treats it as 2 values while it is a single column.
reswhich is the result set of mysql?