如何设计该图的查询语句?

bluewing500 2005-06-15 06:19:31
先看看下面的抓图:

想实现的查询方式:
1、当客户,年,月,日不选择的时候则查询所有的数据.
2、当选择客户时,可分别按年,月,日查询该客户的所有数据。
3、当不选客户时,可分别按年,月,日查询符合条件的数据。

请高手详细给个查询语句。我真的拿它没办法了。
在线等解答。。。

...全文
104 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackycxg 2005-06-16
  • 打赏
  • 举报
回复
这样至少可以说明楼主逻辑还是比较清晰的

不能这么多IF  END IF下来会很累的
jarraytan 2005-06-16
  • 打赏
  • 举报
回复
点 管理

=====================

不是一样的语句麽,就在那吹
我用了比你们更好的方法

嘿嘿 -_-
xuyadong 2005-06-16
  • 打赏
  • 举报
回复
楼主还有ubb呢。呵呵.[img] [/img]
csdn不吃这套。
超级大笨狼 2005-06-16
  • 打赏
  • 举报
回复
一堆if else能解决,耐心。
qpgsd 2005-06-16
  • 打赏
  • 举报
回复
<a href=?page=2&chk_name=<%=request("chk_name")&name=<%=request("name")%>&......>下一页</a>

上条request("chk_name")前漏了"=",不好意思
qpgsd 2005-06-16
  • 打赏
  • 举报
回复
分页时要把所有用到的查询变量都加到URL后面。即
<a href=?page=2&chk_name=<%request("chk_name")&name=<%=request("name")%>&......

建议在搜索页面中,所有从表单过来的变量都用 request("name") 形式获得。方便从URL附带变量到下页
madpolice 2005-06-16
  • 打赏
  • 举报
回复
没看到分页代码啊
bluewing500 2005-06-16
  • 打赏
  • 举报
回复
没办法结贴的??
bluewing500 2005-06-16
  • 打赏
  • 举报
回复
:)
bluewing500 2005-06-16
  • 打赏
  • 举报
回复
问题我已解决.谢谢大家的支持.灌水的就不给分了.其它的平分了吧.:)
bluewing500 2005-06-16
  • 打赏
  • 举报
回复
问题我已解决,我用了比你们更好的方法.方法如下:

strSQL="SELECT * FROM cart WHERE cartID LIKE '%%'"
If Request.form("chk_name")="YES" Then
name = Request.form("name")
strSQL = strSQL & " and name LIKE '%" & name & "%'"
links = links & "name="&name&"&chk_name=YES"
End if
if Request.form("chk_year")="YES" Then
syear =Request.Form("year")
strSQL =strSQL & " and year(tm)=" & syear & ""
links = links & "&syear="&syear&"&chk_year=YES"
End if
If Request.form("chk_month")="YES" Then
smonth =Request.Form("month")
strSQL =strSQL & " and month(tm)=" & smonth & ""
links = links & "&smonth="&smonth&"&chk_month=YES"
End if
If Request.form("chk_day")="YES" Then
sday =Request.Form("day")
strSQL =strSQL & " and day(tm)=" & sday & ""
links = links & "&sday="&sday&"&chk_day=YES"
End if
strSQL =strSQL & " Order by cartID "&fs&""

set list=server.createobject("adodb.recordset")
list.open strSQL,conn,1,2

不过又出现了新的问题.就是分页显示正确.可是打开打二页的时候返回的结果却是查询所有数据的分页.真是麻烦.想集成所有的查询在一个页面上却碰到这么多问题.唉~基础不好就是这样了.谁能帮忙解决这个问题?分全归他.谢谢.
bluesky98 2005-06-15
  • 打赏
  • 举报
回复
应为:if (year1<>"" and month1<>"") and day1<>"" then ....
jarraytan 2005-06-15
  • 打赏
  • 举报
回复
哦。不好意思,写错了点。

sql="select * from tab where 1=1 "
if year1<>"" and month1<>"" and day1<>"" then sqls=sqls & " AND year=" & year & " and month =" ..........
if client<>"" then sqls=sqls & " AND client='" & client & "'"

rs.open sql,conn,1,1
jarraytan 2005-06-15
  • 打赏
  • 举报
回复
这个很简单的,就是组合语句。

sql="select * from tab where 1=1 "
if year1<>"" and month1<>"" and day1<>"" then sqls=sqls & " year=" & year & " and month =" ..........
if client<>"" then sqls=sqls & " client='" & client & "'"

rs.open sql,conn,1,1

就是这样的了,你自己按照这种方法写适合你自己的表的语句。

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧