underscore
underscore

Reputation: 6887

Unknown column missing WHERE clause mysql command line

I have an ssh layer. From that i'm going to get data via mysql shell. But when i use where clause inside a select function. it says bellow error message

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

This is says

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

What's the issue?

Upvotes: 1

Views: 884

Answers (2)

Parixit
Parixit

Reputation: 3855

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 which is not of type int.

Please try following:

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

Upvotes: 2

Mark
Mark

Reputation: 8451

You don't have single quote (') in your SM_ID = 802350570V'. It should be like this:

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

Upvotes: 2

Related Questions