在bash中从mysql读取多行时出错

在bash中从mysql读取多行时出错,mysql,bash,shell,Mysql,Bash,Shell,在互联网上,在bash中从mysql db读取多行数据的方法如下: i=0 while read relation_id do echo "Record $(( i++ )) $relation_id" done < <(mysql -u$db_user -p$db_password -h$db_host -D$db_name -se "SELECT id where connection_id=$id") i=0 当读取关系\u id时 做 echo“记录$((i++)$关系

在互联网上,在bash中从mysql db读取多行数据的方法如下:

i=0
while read relation_id
do
  echo "Record $(( i++ )) $relation_id"
done < <(mysql -u$db_user -p$db_password -h$db_host -D$db_name -se "SELECT id where connection_id=$id")
i=0
当读取关系\u id时
做
echo“记录$((i++)$关系\u id”

done<删除空格done<删除空格done<已经尝试过它给出的
temp.sh:line 11:意外标记附近的语法错误(''error'请重新检查代码,我只指出了明显的错误,但您的查询似乎也不正确。它应该类似于,
mysql-u(username)-p(password)-se“SELECT id from(database)。(table)where relation_id=(id)”
已经尝试过它给出了
temp.sh:line 11:意外标记附近的语法错误(“`error请重新检查代码,我只指出了明显的错误,但您的查询似乎也不正确。它应该类似于,
mysql-u(用户名)-p(password)-se“从(数据库)中选择id)。(表)其中关系_id=(id)”
是,我正在使用相同的查询执行其他操作。所有引用的变量在命令上方正确定义?是,我正在使用相同的查询执行其他操作。所有引用的变量在命令上方正确定义?
temp.sh: line 11: syntax error near unexpected token `<'
temp.sh: line 11: `done < <(mysql -u$db_user -p$db_password -h$db_host -D$db_name -se "SELECT id where connection_id=$id")'