[free]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 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
if classname="" then sql=sql&" ORDER BY DownloadsNumber DESC"
if classname="下载量降序" then sql=sql&" ORDER BY DownloadsNumber DESC"
if classname="下载量升序" then sql=sql&" ORDER BY DownloadsNumber ASC"
if classname="有效期降序" then sql=sql&" ORDER BY AvailabilityDate DESC"
if classname="有效期升序" then sql=sql&" ORDER BY AvailabilityDate ASC"
if classname="采集日期降序" then sql=sql&" ORDER BY DownloadsDate DESC"
if classname="采集日期升序" then sql=sql&" ORDER BY DownloadsDate ASC"
if classname="数据日期降序" then sql=sql&" ORDER BY YearMonth DESC"
if classname="数据日期升序" then sql=sql&" ORDER BY YearMonth ASC"
这个是我写的查询
多条件查询,我自认为不错
你可以看看适合你不[/free]
[[it] 本帖最后由 lili0610 于 2008-12-1 17:51 编辑 [/it]]