sql语句的问题???在线等
在做查询时候,没有输入什么东东,但结果,把表中的所有记录都显示出来.
select * from toptitle where ifel=0 and title like '% "&keyword& "% ' order by addtime desc
用reponse.write 打印出来
select * from toptitle where ifel=0 and title like '%% ' order by addtime desc
在SQL查询分析器中显示全部记录,前台也是一样,不知道什么原因.
数据库是MSSQL
------解决方案--------------------如果keyword是空,那么
and title like '% "&keyword& "% '
相当于
and 1
------解决方案--------------------可以判断一下keyword的值是否为空!
------解决方案--------------------select * from toptitle where ifel=0 and title like ' "&keyword& " ' order by addtime desc
这样应该就不会了
------解决方案--------------------if Request( "keyword ") <> " " then
Sql = "select * from toptitle where ifel=0 and title like '% "&keyword& "% ' order by addtime desc "
else
Response.Write "没条件! "
Response.End
end If