Reputation: 55
I have a table 'client' where a column 'wipes' is currently filled with Y or N. I want to change Y and N to 1 and 0. I am trying this query and getting the error "Unknown column 'Y' in 'where clause'" I have tried every combination of with backticks, without backticks, single quotes, etc... Why does it think that 'Y" is a column?
UPDATE client
SET wipes = `1`
WHERE wipes = `Y`;
Thank you!
Upvotes: 2
Views: 1209
Reputation: 55
I Got it, slightly stupid. It should be
WHERE wipes LIKE 'Y';
that worked. I don't know if it would be the same in every sql version. But I'm using phpMyadmin.
Upvotes: 1
Reputation: 1144
Maybe you should use a single quote like
UPDATE client
SET wipes = 1
WHERE wipes = 'Y';
UPDATE `client` SET `wipes` = CASE
WHEN wipes= 'Y' THEN 1
WHEN wipes = 'N' THEN 0
END
Upvotes: 3