Search code examples
sqlstring-constant

SQL unknown column in where clause


I get this error:

Error: UPDATE stats SET stat2='2' WHERE name=views
Unknown column 'views' in 'where clause'

In the table 'name' is the column, and 'views' is a value in that column.

As far as I can tell from the documentation the statement "WHERE name=views" should be read as "WHERE {column}={cell value}", whereas the error is inferring that the column name is the second value.


Solution

  • You need to put the values within '' since it's a string value

    UPDATE stats SET stat2='2' WHERE name='views'