ASP+ACCESS 多项目模糊查询问题
为什么生成的语句在ACCESS查询就有结果,用ASP查询就什么也查不出来,在ASP里一个条件就没问题生成的语句:selecttop10*fromdv_bbs1whereT...
为什么生成的语句在ACCESS查询就有结果,用ASP查询就什么也查不出来,在ASP里一个条件就没问题
生成的语句:
select top 10 * from dv_bbs1 where Topic like'%人物%' or Topic like'%时间%' or Topic like'%地点%' and ParentID=0 order by DateAndTime desc
Keyword="人物 时间 地点"
Keys=split(Keyword," ")
lsqlstr="select top 10 * from dv_bbs1 where "
lenarr=UBOUND(Keys)
for i=0 to lenarr
if i=lenarr then
lsqlstr=lsqlstr&"Topic like'%"&Keys(i)&"%' "
else
lsqlstr=lsqlstr&"Topic like'%"&Keys(i)&"%' or "
end if
next
lsqlstr=lsqlstr&"and ParentID=0 order by DateAndTime desc"
lrs.open lsqlstr,fconn,1,1
while not lrs.eof
re=re&"<li>"&lrs("Topic")&"</li>"
lrs.movenext
wend
lrs.close
response.Write(re) 展开
生成的语句:
select top 10 * from dv_bbs1 where Topic like'%人物%' or Topic like'%时间%' or Topic like'%地点%' and ParentID=0 order by DateAndTime desc
Keyword="人物 时间 地点"
Keys=split(Keyword," ")
lsqlstr="select top 10 * from dv_bbs1 where "
lenarr=UBOUND(Keys)
for i=0 to lenarr
if i=lenarr then
lsqlstr=lsqlstr&"Topic like'%"&Keys(i)&"%' "
else
lsqlstr=lsqlstr&"Topic like'%"&Keys(i)&"%' or "
end if
next
lsqlstr=lsqlstr&"and ParentID=0 order by DateAndTime desc"
lrs.open lsqlstr,fconn,1,1
while not lrs.eof
re=re&"<li>"&lrs("Topic")&"</li>"
lrs.movenext
wend
lrs.close
response.Write(re) 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询