user3513510
user3513510

Reputation: 19

Error: Unknown column <value> in 'where clause'

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

Answers (5)

fgallinari
fgallinari

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

jmail
jmail

Reputation: 6134

you should insert your ' ' in your where clause single quote

UPDATE Parts SET Quantity=20 WHERE Part = 'keks'

Upvotes: 1

Sablefoste
Sablefoste

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

xdazz
xdazz

Reputation: 160833

You need quotes:

UPDATE Parts SET Quantity=20 WHERE Part = 'keks'

Upvotes: 1

Alex
Alex

Reputation: 11579

It should be

WHERE Part = 'keks'

Upvotes: 0

Related Questions