ITPub博客

首页 > 数据库 > MySQL > MySQL的sql语句取shell程序中的for in多变量一例

MySQL的sql语句取shell程序中的for in多变量一例

原创 MySQL 作者:chenfeng 时间:2017-11-07 14:35:05 0 删除 编辑
#!/bin/bash
a=(`cat time.txt`)
b=(`cat sum.txt`)
for (( i = 0; i < 38; i++))
do
/bin/mysql -u test -p'test' -h localhost -P 3306 <<EOF
update billing.test set scan_first_sum='${b[$i]}' where project='zjpj' and date='${a[$i]}';
select * from chenfeng.test where project='zjpj' and date='${a[$i]}' and scan_first_sum='${b[$i]}';
EOF
done
#echo ${a[$i]} ${b[$i]}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15498/viewspace-2146935/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
交流MySQL,PolarDB/PolarDB-X,PostgreSQL,MongoDB和Redis技术。

注册时间:2015-12-07

  • 博文量
    784
  • 访问量
    2691653