将 url 变量放在 ’where’ 之后sql查询中的语句
我有一个内部冷聚变脚本。我想将 url.variable 放入 sql select 语句中,如下所示:
SELECT *
FROM table1 a JOIN table2 b ON a.id=b.id
WHERE #a.url.variable# LIKE'%test%'
当我将变量放在单词“WHERE”之后时,我似乎无法让它显示任何数据
I have a in house cold fusion script. i want to put the url.variable into the sql select statement as follows:
SELECT *
FROM table1 a JOIN table2 b ON a.id=b.id
WHERE #a.url.variable# LIKE'%test%'
I cant seem to get it to display any data when I put the variable right after the word 'WHERE'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在其周围放置散列,如下所示:
在这种情况下,您不能使用 cfqueryparam,因此我还要确保在查询中使用 URL.variable 之前,它已经转义了任何 SQL 注入字符。
You need to put hashes around it as follows:
You can't use a cfqueryparam in this case so I'd also ensure that URL.variable has been escaped of any SQL injection characters before using it in your query.
如果它是 cfscipt 块中的字符串,您将需要:
或者如果不是,请确保它包含在
If it's a string in a cfscipt block you will need:
Or if not, make sure it's contained in a