2

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!

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
QuadB
  • 55
  • 10
  • See https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql – Bill Karwin Sep 14 '20 at 19:02
  • Does this answer your question? [When to use single quotes, double quotes, and backticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql) – Progman Sep 14 '20 at 19:29

2 Answers2

3

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
Rony Nguyen
  • 1,067
  • 8
  • 18
1

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.

QuadB
  • 55
  • 10