ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

mysql – 多一个WHERE条件导致错误:您的SQL语法中有错误;

2019-07-16 09:24:19  阅读:215  来源: 互联网

标签:mysql coldfusion sql


好.每当我尝试在其中获得多个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的事实.要么完全重命​​名该列(首选),要么使用反引号将其转义.

另外,您应该在所有变量查询参数上使用cfqueryparam. CFQueryparam提供了许多好处(数据类型检查,提高查询性能等).其中最重要的是帮助防止sql注入,这可能是一个问题even with quoted strings.

标签:mysql,coldfusion,sql
来源: https://codeday.me/bug/20190716/1476846.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有