简体   繁体   English

Mysql 错误 #1054 - 更新时“where 子句”中的未知列“Y”

[英]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?我有一个表 'client',其中一列 'wipes' 当前填充了 Y 或 N。我想将 Y 和 N 更改为 1 和 0。我正在尝试此查询并收到错误“Unknown column 'Y' in ' where 子句'" 我已经尝试了带反引号、不带反引号、单引号等的所有组合......为什么它认为 'Y" 是一列?

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.我不知道它是否在每个 sql 版本中都相同。 But I'm using phpMyadmin.但我正在使用 phpMyadmin。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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