欢迎光临
我们一直在努力

ASP中巧用Split()函数生成SQL查询语句

建站超值云服务器,限时71元/月

split 程序代码

<%attribs="商场名^^快餐店名^^报停名"

names=split(attribs,"^^")

i=0

for each name in names

response.write names(i)&"<br>"

i=i+1

next%>

程序拆分结果:

商场名

快餐店名

报停名

根据 split 结果生成 sql 语句

<%attribs="商场名^^快餐店名^^报停名"

names=split(attribs,"^^")

i=0

sql="select top 10 * from tablename where"

for each name in names

if names(i)="商场名" then

sql=sql+" or 商场 like %"&names(i)&"%"

end if

if names(i)="快餐店名" then

sql=sql+" or 快餐店 like %"&names(i)&"%"

end if

if names(i)="报停名" then

sql=sql+" or 快餐店 like %"&names(i)&"%"

end if

i=i+1

next

sql=sql+" ordey by id desc"

sql=replace(sql, "where or", "where")

response.write sql%>

程序运行结果:

select top 10 * from tablename where 商场 like %商场名% or 快餐店 like %快餐店名% or 快餐店 like %报停名% ordey by id desc

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP中巧用Split()函数生成SQL查询语句
分享到: 更多 (0)

相关推荐

  • 暂无文章