I am quite new in shell scripting and straight-away I am facing a problem. I want to query mysql database and store the result in an array in shell script. The query I am using is:
result=`mysql -e "select SequenceID from wsnapp.apptrafficnew where DateTime between '2012-12-27 11:40:00' AND '2012-12-27 12:30:00';"`
and I am also able store this data into an array by using:
array=( $( for i in $result ; do echo $i ; done ) );
but the problem is, it does not store the actual values. when I try to access the elements of array it shows something like that:
array[1]=SequenceID[1]
here I am only storing integers(1,2,3,4...) in my database so my actual value stored is 1 not the SequenceID[1].
I want to do some integer operations on the elements on array. So How do I store the actual values?
Please help.
result=`mysql -e "select SequenceID from wsnapp.apptrafficnew where DateTime between '2012-12-27 11:40:00' AND '2012-12-27 12:30:00';"`
and I am also able store this data into an array by using:
array=( $( for i in $result ; do echo $i ; done ) );
but the problem is, it does not store the actual values. when I try to access the elements of array it shows something like that:
array[1]=SequenceID[1]
here I am only storing integers(1,2,3,4...) in my database so my actual value stored is 1 not the SequenceID[1].
I want to do some integer operations on the elements on array. So How do I store the actual values?
Please help.