gpt4 book ai didi

mysql - 不止一个 WHERE 条件导致错误 : You have an error in your SQL syntax;

转载 作者:可可西里 更新时间:2023-11-01 07:47:34 25 4
gpt4 key购买 nike

嗯。每当我尝试在 a 中获取多个 WHERE 条件时,它只会给我一个 SQL 语法错误。

错误:

Error Executing Database Query.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read = '0'' at line 3

Resources:
Enable Robust Exception Information to provide greater detail about the source of errors. In the Administrator, click Debugging & Logging > Debug Output Settings, and select the Robust Exception Information option.
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.
Browser Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36
Remote Address ::1
Referrer
Date/Time 21-Oct-14 08:27 PM

SQL 查询本身:

<cfquery name = "getUserAlerts" datasource = "#DSN#">
SELECT *
FROM user_alerts
WHERE client_id = '#clientUser.id#'
AND read = '0'
</cfquery>

在我看来,SQL 查询没有任何问题。它应该可以工作,有没有人能看到我写的错误?或者可能给出修复?

提前致谢!

编辑:

感谢您给我的快速答复。反引号起作用了!谢谢大家!

最佳答案

错误可能是由于 READ is a reserved word .要么完全重命​​名该列(最好),要么使用反引号对其进行转义。

顺便说一句,您应该对所有可变查询参数使用 cfqueryparamCFQueryparam提供了许多好处(数据类型检查、提高查询性能等)。其中最重要的一项是帮助防止 sql 注入(inject),这可能是一个问题 even with quoted strings .

关于mysql - 不止一个 WHERE 条件导致错误 : You have an error in your SQL syntax;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26493770/

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