mysql有趣的语句——bash使用mysql结果

select concat(',',group_concat(tab_campaign.OFFER_id separator ' '),' ') from tab_campaign where INSTR(',2055,2087,2086,2058,2057,2056,2064,2063,2062,2061,2060,2059,',offer_id)

2058 $ cat fixprice

!/bin/bash --login

成为login shell,才能读取.bashrc的Alias设置

=====================

YuanHui.HE

[email protected]

=====================

shopt -s expand_aliases

使用shell内置命令shopt命令来开启alias扩展选项

HOSTNAME="localhost" #数据库信息
PORT="3306"
USERNAME="root"
PASSWORD="!VMD1kult"

DBNAME="mc_new_arch_mona" #数据库名称
TABLENAME="tab_campaign"

COMMAND1="mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD} ${DBNAME}"
for day in {1..6}
do
date="2017120"${day}
while read campid PriceLabel Currency Type
do
[ "${campid}" != "CAMPAIGN_ID" ] && redisc hmset counter_campaign_${campid} cprice_${date} ${PriceLabel} ccurrency_${date} ${Currency} ctype_${date} ${Type}
done< <(echo "select * from ProblemCampPrice_2120_2121;"|${COMMAND1})
done


参考:
redisc hmset counter_campaign_5712 cprice_20171206 4.5 ccurrency_20171206 CNY ctype_20171206 CPA

HOSTNAME="localhost" #数据库信息
PORT="3306"
USERNAME="root"
PASSWORD="!VMD1kult"

DBNAME="mc_new_arch_mona" #数据库名称
TABLENAME="tab_campaign"

COMMAND1="mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD} ${DBNAME}

for day in {1..6}
do
date="2017120"${day}
while read campid PriceLabel Currency Type
do
echo "redisc hmset counter_campaign_${campid} cprice_${date} ${PriceLabel} ccurrency_${date} ${Currency} ctype_${date} ${Type}"
return
done< <(echo "select * from ProblemCampPrice where campaign_id=${campid};" | ${COMMAND1})
done

你可能感兴趣的:(mysql有趣的语句——bash使用mysql结果)