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
解决方案
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'