ASP程序设计中多关键字查询时,将以空格分开的关键字转换成查询条件的过程?

来源:百度知道 编辑:UC知道 时间:2024/07/05 09:08:25

上面的该用or 查询的范围要广点:
sql="select * from 表名 where"
str="问题 进行 补充"
arr=split(str," ")
tj=""
for i=0 to ubound(arr)
if tj="" then
tj=tj&" 字段名 like'%"&arr(i)&"%' "
else
tj=tj&" or 字段名 like'%"&arr(i)&"%' "
end if
next
sql=sql&tj
现在的sql就是你要才查询语句

sql="select * from [tablename] where"
str="问题 进行 补充"
arr=split(str," ")
lenarr=ubound(arr)
for i=0 to lenarr
if i=lenarr then
temp=temp&" 字段名 like'%"&arr(i)&"%' "
else
temp=temp&" 字段名 like'%"&arr(i)&"%' and "
end if
next
newsql=sql&temp
response.Write(newsql)