简体   繁体   中英

Mysql error #1054 - Unknown column 'Y' in 'where clause' on Update

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!

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM