ASP提交有特殊符号如通配符等查询数据库的sql语句怎么写?

来源:百度知道 编辑:UC知道 时间:2024/06/05 18:28:04
比如,我在搜索框中输入:30%
我要搜索的是数据库name字段中,有30%这几个字符的。而不是通配符。
还有一些通配符,如:+
SQL语句中就这样写:where name like '%"&texts&"%'
但一执行就进入死循环了。
二楼的。。 你那不对啊。我如果这样输入搜索呢S+2pv
麻烦谁给写个通用的啊。

function formatStr(str)
tempstr=replace(str,"'","''")
tempstr=replace(tempstr,"[","[[]")
tempstr=replace(tempstr,"%","[%]")
tempstr=replace(tempstr,"_","[_]")
tempstr=replace(tempstr,"^","[^]")
formatStr=tempstr
end function

where name like '%"&formatStr(texts)&"%'

%是sql里的通配符,你想使用%的话,好像是要加个“_”,具体我不记得了

30[%]

补充:S+2pv 什么意思?