我在shell中的一个变量中存储了一个值。如下所示
app=$(mysql -uroot -p123456 -e 'SELECT applicant FROM `leave` where status="Applied" and applying_date= curdate()' comviva|tail -1);但是使用这个变量,如果我想要更新任何列,我就会遇到错误。下面是错误。更新命令:
mysql -uroot -p123456 -e "update leave set status=\"pending\" where applicant=\"$app\"" comviva;遇到的错误:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'leave set status="pending" where applicant="a"' at line 1发布于 2014-04-21 14:03:28
错误是由于在语句中使用、LEAVE作为标识符造成的。
因此,要在语句中将其用作标识符,请在其两边使用反勾号。
mysql -uroot -p123456 -e "update `leave` set status='pending' where applicant='$app'" comviva;发布于 2014-04-21 13:58:39
请用这个
mysql -uroot -p123456 -e "update leave set status='pending' where applicant='$app'" comviva;https://stackoverflow.com/questions/23191663
复制相似问题