【发布时间】:2017-07-30 21:24:46
【问题描述】:
我目前正在编写一个 shell 脚本。
我想在 shell 脚本中将“学生”表中“余额”列的包含修改为 "balance=balance-$deduct"。
我正在 shell 中执行以下行
mysql -h "$host" -u "$user" --password="$pass" --database="$db" -e "UPDATE student SET balance=balance-$deduct WHERE pid=$pid";
这里我正确指定了主机、用户名和密码,并且我在$deduct中存储了一个数值
但是当我执行脚本时出现以下错误:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE pid=132054' at line 1
我哪里错了?
谢谢
【问题讨论】: