Reputation: 19
got a problem with mysql
.
im trying to update an value, from an existing table entry.
The table is called Parts
the columns are Part
and Quantity
one of the entries has Part=keks
and Quantity=10
now im trying to:
UPDATE Parts SET Quantity=20 WHERE Part = keks
but this error appear:
Error: Unknown column 'keks' in 'where clause'
Upvotes: 0
Views: 664
Reputation: 133
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
.
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'
Upvotes: 1
Reputation: 6134
you should insert your ' '
in your where clause single quote
UPDATE Parts SET Quantity=20 WHERE Part = 'keks'
Upvotes: 1
Reputation: 4182
You need to put the search term in quotes:
UPDATE Parts SET Quantity=20 WHERE Part = keks
becomes
UPDATE Parts SET Quantity=20 WHERE Part = 'keks'
Note, the Quantity could also be in quotes, but because it is a number, it doesn't need to be.
Upvotes: 1