新闻动态

   

您现在的位置是:首页 » 新闻动态 » 网站技术


asp 多条件查询语句sql写法


人气: 3845  日期: 2011-04-08  作者: 大向网络  [打印本文]

url="?temp1233=1"
   sql="SELECT * FROM houses where 1=1"
 pianqu=request("pianqu") '所在片区
 if pianqu=""   then
    pianqu=""
 else
  sql=sql&" and pianqu='"&pianqu&"'"
  url=url&"&pianqu="&pianqu&""
 end if
 fid=request("fid")  '房源ID
 if fid=""   then
   fid=""
 else
  sql=sql&" and id="&fid&""
  url=url&"&fid="&fid&""
 end if
 shi=request("shi")  '室
 if shi=""   then
   shi=""
 else
  sql=sql&" and shi="&shi&""
  url=url&"&shi="&shi&""
 end if
 ting=request("ting")  '厅
 if ting=""   then
   ting=""
 else
  sql=sql&" and ting="&ting&""
  url=url&"&ting="&ting&""
 end if
 wei=request("wei")  '卫
 if wei=""   then
   wei=""
 else
  sql=sql&" and wei="&wei&""
  url=url&"&wei="&wei&""
 end if
 yangtai=request("yangtai")  '阳台
 if yangtai=""   then
   yangtai=""
 else
  sql=sql&" and yangtai="&yangtai&""
  url=url&"&yangtai="&yangtai&""
 end if
 
 loucengsmall=request("loucengsmall") '楼层范围小数字
 if loucengsmall=""  then
   loucengsmall=""
 else
  sql=sql&" and cint(louceng) >= "&loucengsmall&""
  url=url&"&loucengsmall="&loucengsmall&""
 end if
 
  loucengbig=request("loucengbig") '楼层范围大数字
 if loucengbig=""  then
   loucengbig=""
 else
  sql=sql&" and cint(louceng) <= "&loucengbig&""
  url=url&"&loucengbig="&loucengbig&""
 end if
 
  mianjismall=request("mianjismall") '建筑面积小数字
 if mianjismall=""  then
   mianjismall=""
 else
  sql=sql&" and cint(mianji) >= "&mianjismall&""
  url=url&"&mianjismall="&mianjismall&""
 end if
 
 mianjibig=request("mianjibig") '建筑面积大数字
 if mianjibig=""  then
   mianjibig=""
 else
  sql=sql&" and cint(mianji) <= "&mianjibig&""
  url=url&"&mianjibig="&mianjibig&""
 end if
 
  jiagesmall=request("jiagesmall") '价格小数字
 if jiagesmall=""  then
   jiagesmall=""
 else
  sql=sql&" and cint(jiage) >= "&jiagesmall&""
  url=url&"&jiagesmall="&jiagesmall&""
 end if
 
 jiagebig=request("jiagebig") '价格大数字
 if jiagebig=""  then
   jiagebig=""
 else
  sql=sql&" and cint(jiage) <= "&jiagebig&""
  url=url&"&jiagebig="&jiagebig&""
 end if
 
 fangwuleixing=request("fangwuleixing") '房源类型
 if fangwuleixing=""   then
    fangwuleixing=""
 else
  sql=sql&" and fangwuleixing='"&fangwuleixing&"'"
  url=url&"&fangwuleixing="&fangwuleixing&""
 end if
 
 zhuangxiu=request("zhuangxiu")  '装修类型
 if zhuangxiu=""   then
    zhuangxiu=""
 else
  sql=sql&" and zhuangxiu='"&zhuangxiu&"'"
  url=url&"&zhuangxiu="&zhuangxiu&""
 end if
 
 
  xiaoqu=request("xiaoqu")  '小区地段
 if xiaoqu=""   then
    xiaoqu=""
 else
  sql=sql&" and xiaoqu like  '%"&xiaoqu&"%'"
  url=url&"&xiaoqu="&xiaoqu&""
 end if

  上一篇:PHP 多条件搜索 sql写法
  下一篇:html5自带得表单验证代码 做验证再也不用那么复杂了
相关文章(Tags:asp)