day1=1
music=request("music")
m_name=request("m_name")
spname=request("spname")
date1=request("date1")
region=request("region")
classname=request("classname")
date2=request("date2")
'if Trim(Request.QueryString("page"))="" then
sql="Select BellID,SongName,SingerName,Price,AvailabilityDate,SpName,Region,DownloadsNumber,DownloadsDate,YearMonth from DownloadsData where"
if music<>"" then sql=sql&" SongName like '%"&music&"%' AND"
if m_name<>"" then sql=sql&" SingerName like '%"&m_name&"%' AND"
if spname<>"" then sql=sql&" SpName like '%"&spname&"%' AND"
if region<>"" then sql=sql&" Region like '%"®ion&"%' AND"
if date1<>"" and date2="" then sql=sql&" YearMonth ='"&date1&"-"&day1&"' AND"
if date2<>"" and date1="" then sql=sql&" YearMonth ='"&date2&"-"&day1&"' AND"
if date1<>"" and date2<>"" then sql=sql&" YearMonth >= '"&date1&"-"&day1&"' AND YearMonth <= '"&date2&"-"&day1&"' AND"
'If date1="" Then sql=sql&" DownloadsDate<'"&year1&"' and DownloadsDate>'"&month1&"' AND"
if right(sql,5)="WHERE" then sql=left(sql,clng(len(sql))-5) '解决所有参数都为空的情况
if right(sql,3)="AND" then sql=left(sql,clng(len(sql))-3) '去掉参数最后的and
这个应该适合你,是6个条件查询
还有排序我就不放上面了,你自己再加吧?
不管理是你四个条件还是几十个条件,这个程序应该都可以满足