ASP搜索代码问题..求教..

来源:百度知道 编辑:UC知道 时间:2024/06/23 17:00:27
<%'获取查询字段
keyword=replace(trim(request("keyword")),"'","")
city1=replace(trim(request("city1")),"'","")
price=replace(trim(request("price")),"'","")
%>
<%
'查询语句开始
sql="select * from line where 0=0"
if keyword<>"" then
sql=sql&" and title like'%"&keyword&"%'"
end if
if city1<>"" then
sql=sql&" and go_day="&city1&""
end if
'价格区域
if price<>"" then
if price=1 then
sql=sql&" and price<=200"
end if
if price=2 then
sql=sql&" and (price between 200 and 400)"
end if
if price=3 then
sql=sql&" and (price between 400 and 600)"
end if
if price=4 then
sql=sql&" and (price between 600 and 800)"

就楼主说的问题,问题在于查询语句中的(price between 200 and 400),这个是数值型的判断,所以不能更改为字符型!如果一定要改为字符型,可以用(val(price) between 200 and 400)的方式来做! 也就是用VLA函数将price字段转化为字符型!

<%'获取查询字段
keyword=replace(trim(request("keyword")),"'","")
city1=replace(trim(request("city1")),"'","")
price=replace(trim(request("price")),"'","")
%>
<%
'查询语句开始
sql="select * from line where 0=0"
if keyword<>"" then
sql=sql&" and title like'%"&keyword&"%'"
end if
if city1<>"" then
sql=sql&" and go_day='"&city1&"'"
end if
'价格区域
if price<>"" then
if price=1 then
sql=sql&" and price<=200"
end if
if price=2 then
sql=sql&" and (price between 200 and 400)"
end if
if price