shell 改mysql

mysql -h 100.200.300.400  -uaaaaa -pxxx   -P3306 -e "use pth;select user_id,min(start_time),attendance_type from tb_kkkkkk where year=2023 and month=4 and day=21 and start_time is not null group by user_id" >rs2222.txt

sed -i 's#\t# #g' rs2222.txt


sed -i '1d' rs2222.txt


while read line
do
echo $line
a=$(echo $line|awk -F'[ ]+' '{print $1}')
b=$(echo $line|awk -F'[ ]+' '{print $2}')
c=$(echo $line|awk -F'[ ]+' '{print $3}')
d=$(echo $line|awk -F'[ ]+' '{print $4}')
#echo $a
#echo $b $c
#echo $d
echo "update mmm_pppp_list set start_time='${b} ${c}' ,final_start_time='${b} ${c}', ppp_type='${d}' where year=2023 and month=4 and day=21 and user_id=${a};" >>sql2222.txt
done < rs2222.txt

posted @ 2023-04-23 19:30  滴滴滴  阅读(22)  评论(0编辑  收藏  举报