1

我有一个 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'

有什么问题?

4

2 回答 2

2

'SM_ID = 802350570V'. 它应该是这样的:

echo $ssh->exec("mysql -ppass -u root esoftcar_col-b -e 'select * from `student_master` where `SM_ID` = \"802350570V\"'");
于 2013-10-04T06:10:13.790 回答
2

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

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

请尝试以下操作:

`echo $ssh->exec("mysql -ppass -u root xxxx_col-b -e 'select * from student_master where SM_ID =\"802350570V\"'");`
于 2013-10-04T06:13:11.200 回答