|
主题: 多字段查询?
|
songweimin
职务:普通成员
等级:1
金币:0.0
发贴:3
|
#12004/4/15 11:48:04
如何实现后台多字段查询呢?
|
janlay
职务:管理员
等级:7
金币:28.0
发贴:7244
|
#22004/4/15 13:08:50
说清楚你的问题。
如果你不知道怎么问,先看看软件的帮助文档。
|
绿茶
职务:普通成员
等级:8
金币:10.0
发贴:19267
|
#32004/4/15 14:12:09
if alltime = "" then st = rf("st") et = rf("et")
y1 = rf("y1") m1 = rf("m1") d1 = rf("d1") h1 = rf("h1") mm1 = rf("mm1")
y2 = rf("y2") m2 = rf("m2") d2 = rf("d2") h2 = rf("h2") mm2 = rf("mm2") if st="1" then ifs = " (datediff(n,'" & dtm1 & "',createtime)>=0 " else ifs = " (datediff(n,'" & dtm1 & "',createtime)>0 " end if if et="1" then ifs = ifs & " and datediff(n,'" & dtm2 & "',createtime)<=0) " else ifs = ifs & " and datediff(n,'" & dtm2 & "',createtime)<0) " end if ifs=" (createtime between '"& dtm1 &"' and '"& dtm2 &"') " else ifs = "" end if if ifs<> "" then ifs = " and " & ifs
sql="SELECT mobile FROM paper_chance "&_ "WHERE (mobile IN (SELECT mobile FROM paper_chance "&_ " WHERE (ischance = 1 "&ifs&") "&_ " GROUP BY mobile HAVING (COUNT(*) >= 5))) "&_ " AND (content like '"&key&"%') "&ifs&" order by mobile "
|
songweimin
职务:普通成员
等级:1
金币:0.0
发贴:3
|
#42004/4/15 18:53:28
哎 看不懂啊 给加点注释
|
绿茶
职务:普通成员
等级:8
金币:10.0
发贴:19267
|
#52004/4/16 8:57:07
sql="SELECT mobile FROM paper_chance "&_ "WHERE (mobile IN (SELECT mobile FROM paper_chance "&_ " WHERE (ischance = 1 "&ifs&") "&_ " GROUP BY mobile HAVING (COUNT(*) >= 5))) "&_ " AND (content like '"&key&"%') "&ifs&" order by mobile "
这语句的条件就是: 在PAPER_CHANCE表中,把标识为真,在某一时间范围内且MOBILE值相同的数据出现5次以上而且有一次内容是KEY相关的内容的手机号取出来
|
绿茶
职务:普通成员
等级:8
金币:10.0
发贴:19267
|
#62004/4/16 9:00:18
sql="select * from "&tb&" where id>0" if msg<>"" then sql=sql& " and message='"& msg &"' end if
if mobile<>"" then sql=sql& " and mobile='"& mobile &"'" end if ...
我想你要的是这种吧
|
czweb
职务:普通成员
等级:1
金币:0.0
发贴:13
|
|