未知列缺少 WHERE 子句 mysql 命令行


Unknown column missing WHERE clause mysql command line

我有一个ssh层。从那里,我将通过mysql shell获取数据。但是当我在选择函数中使用 where 子句时。它说下面的错误消息

echo $ssh->exec("mysql -ppass -u root xxxx -e 'select * from `student_master` where `SM_ID` =802350570V'");

这是说的

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

问题出在哪里?

在这里,您将查询作为参数传递,因此使用 ' 包装查询,但请确保添加转义序列以将查询包装为'

您应该使用 " 来包装不属于 int 类型的列值。

请尝试以下操作:

`echo $ssh->exec("mysql -ppass -u root xxxx_col-b -e 'select * from student_master where SM_ID ='"802350570V'"'");`

您的SM_ID = 802350570V'中没有单引号 ( ' )。它应该是这样的:

echo $ssh->exec("mysql -ppass -u root esoftcar_col-b -e 'select * from `student_master` where `SM_ID` = '"802350570V'"'");