错误:未知列< value>在"where子句"中
问题描述:
遇到了mysql
问题.
im试图从现有表条目中更新值.
im trying to update an value, from an existing table entry.
该表称为Parts
列是Part
和Quantity
其中一个条目具有Part=keks
和Quantity=10
现在我正尝试:
UPDATE Parts SET Quantity=20 WHERE Part = keks
但出现此错误:
Error: Unknown column 'keks' in 'where clause'
答
MySQL解释器理解的是您要更新表Parts
并将列Quantity
设置为20,而列keks
具有相同的值.
What the MySQL interpreter understands is that you want to update the table Parts
and set the column Quantity
as 20 to every row where the column Part
has the same value as a (non-existing) column keks
.
正如其他人已经说过的,如果要告诉解释器将列与值进行比较,则应使用 quotes 包裹该值,如下所示: 'keks'
As other people already said, if you want to tell the interpreter to compare the column to a value, you should wrap the value with quotes, like this: 'keks'
因此,最后您的查询将是:
So, in the end your query will be:
UPDATE Parts SET Quantity=20 WHERE Part = 'keks'