grepsedawk
grepsedawk

Reputation: 3411

[42S22][1054] Unknown column in 'where clause'

I have a statement in which works fine in PHP, but when I try it in MySQL console, I get an error:

sql> UPDATE users SET password = ? WHERE username = ?
(?=Test, ?=test)
[2014-03-07 17:26:31] [42S22][1054] Unknown column 'test' in 'where clause'

I have tried quotes around the ?, and many other options.

It should be a simple WHERE, but it doesn't seem to work in console.

This makes me think it's a bad SQL request, but I can't figure out anything wrong with it.

Upvotes: 2

Views: 3433

Answers (1)

Fabio
Fabio

Reputation: 23510

You need to surround your string with quotes, so use

(?='Test', ?='test')

Otherwise mysql will treat them as columns which actually don't exist in your table

Upvotes: 4

Related Questions