gpt4 book ai didi

mysql - 使用 where 子句时更新中的语法错误

转载 作者:太空宇宙 更新时间:2023-11-03 10:45:20 25 4
gpt4 key购买 nike

我陷入了 update 查询。我正在处理注册表单,如果确认邮件链接被重定向到站点,则更新查询传递并使用确认值更新行。

这是错误信息:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''users' SET 'confirm'='1' WHERE 'com_code'='732aabcb4ad6a03b51e0a55aab998726'' at line 1

请检查我的语法错误之处:

UPDATE 'users' 
SET 'confirm'='1'
WHERE 'com_code'='732aabcb4ad6a03b51e0a55aab998726';

谢谢!

最佳答案

引用标识符使用反引号 ` Identifier Names

Identifiers may be quoted using the backtick character - `. Quoting is optional for identifiers that don't contain special characters, or is a reserved word. If the ANSI_QUOTES SQL_MODE flag is set, double quotes (") can also be used to quote identifiers.

UPDATE `users` 
SET `confirm`='1'
WHERE `com_code`='732aabcb4ad6a03b51e0a55aab998726';

或者如果您的标识符不是关键字或不包含空格等,则根本不使用它们:

UPDATE users 
SET confirm ='1'
WHERE com_code='732aabcb4ad6a03b51e0a55aab998726';

关于mysql - 使用 where 子句时更新中的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32886216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com