返回顶部

收藏

shell脚本读取mysql结果集的值

更多

按行读取sql结果:

while read -a row
do
    echo "..${row[0]}..${row[1]}..${row[2]}.."
done < <(echo "SELECT A, B, C FROM table_a" | mysql database -u $user -p $password)

将sql执行结果读取到shell变量中:

while read a b c
do
    echo "..${a}..${b}..${c}.."
done < <(echo "SELECT A, B, C FROM table_a" | mysql database -u $user -p $password)

标签:shell,mysql

收藏

0人收藏

支持

1

反对

0

发表评论