gpt4 book ai didi

MySQL 查询 + ASP IF Else End IF

转载 作者:行者123 更新时间:2023-11-29 22:56:56 26 4
gpt4 key购买 nike

示例:

Sql = "Select * From tablo Where Baslik = "&strBaslik&" And Ozellik IN ("&strOzellik&") Order By Id Desc"

我想要:

Sql = "Select * From tablo Where Baslik = "&strBaslik&" **IF Not "&strOzellik&" = Then** And Ozellik IN ("&strOzellik&") **End IF** Order By Id Desc"

我该怎么做?

谢谢。

最佳答案

有多种方法可以解决这个问题,其中之一是连接 sSql 查询:

<%
sSql = "Select * From tablo Where Baslik = '"& strBaslik & "' "
If Not strOzellik = "???" Then
sSql = sSql & " And Ozellik IN ('" & strOzellik & "')"
End If
sSql = sSql & " Order By Id Desc"
%>

请注意,我还在 SQL 参数周围添加了单引号,以防输入实际上是字符串。不过,由于 SQL 注入(inject),这种方式并不安全,您可能需要查看 parameterized queries .

关于MySQL 查询 + ASP IF Else End IF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28678786/

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