Query MySQL in Bash return multiple results
How put the following mysql results into an array?
USER=`mysql -h host --user=myuser --password=mypass MYDB -e "SELECT UserID FROM Users WHERE HireDate > $tDate;"` Then Loop while [ ... ]; do $users = "$USER;" done Basically trying to concatenate it into a string delimited by ";" Now once I get the array how do I list it into a log file cat >> /home/me/users/users.log << EOF $USER EOF I know the syntax is ugly but I really have no clue, well very little clue. And thanks for your help! |
See concat_ws : http://dev.mysql.com/doc/refman/5.0/...functions.html
Then just echo $USER to the logfile. Note, use 'echo' to read vars, 'cat' to read files. http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ http://rute.2038bug.com/index.html.gz PS If you're going to be doing a lot of DB manipulation, use a better lang eg Perl. Shell would work, but its doing it the hard way. |
All times are GMT -5. The time now is 03:55 AM. |