将 url 变量放在 ’where’ 之后sql查询中的语句

发布于 2024-12-20 20:44:37 字数 214 浏览 3 评论 0原文

我有一个内部冷聚变脚本。我想将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

音盲 2024-12-27 20:44:37

您需要在其周围放置散列,如下所示:

SELECT * 
FROM table1 a 
JOIN table2 b ON a.id=b.id 
WHERE a.#url.variable# LIKE '%test%'

在这种情况下,您不能使用 cfqueryparam,因此我还要确保在查询中使用 URL.variable 之前,它已经转义了任何 SQL 注入字符。

You need to put hashes around it as follows:

SELECT * 
FROM table1 a 
JOIN table2 b ON a.id=b.id 
WHERE a.#url.variable# LIKE '%test%'

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.

终止放荡 2024-12-27 20:44:37

如果它是 cfscipt 块中的字符串,您将需要:

"SELECT... " & url.variable & " LIKE..."

或者如果不是,请确保它包含在

<cfoutput>
    SELECT... #url.variable# LIKE...
</cfoutput>

If it's a string in a cfscipt block you will need:

"SELECT... " & url.variable & " LIKE..."

Or if not, make sure it's contained in a

<cfoutput>
    SELECT... #url.variable# LIKE...
</cfoutput>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文