Getting ERROR 1054 (42S22) while i am executing the MySQL command in the Terminal

青春壹個敷衍的年華 提交于 2019-12-11 08:46:40

问题


I want to collect the data from the crawlstatus table where status='RECEIVED' and I want to store that data in an file.
When I am trying to do this in the terminal I am getting ERROR 1054 (42S22).

Here is the command that which i used to get the data:

sudo sh -c '/usr/local/mysql/bin/mysql -h localhost -P 3306 --user=root --password=XXXXXXXXXX -e "select count(*) from crawlstatus where status='RECEIVED';" test_navin > size.log'

I am getting the following ERROR:

ERROR 1054 (42S22) at line 1: Unknown column 'RECEIVED' in 'where clause'

Can anyone help me in solving this problem


回答1:


Here, you are passing your query as an argument so wrap query with', but make sure that you add escape sequence to wrap query with'

You should use " to wrap column value.

sudo sh -c '/usr/local/mysql/bin/mysql -h localhost -P 3306 --user=root --password=XXXXXXXXXX -e "select count(*) from crawlstatus where status=\"802350570V\";" test_navin > size.log'


来源:https://stackoverflow.com/questions/23989967/getting-error-1054-42s22-while-i-am-executing-the-mysql-command-in-the-termina

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!