一个有关搜索的问题!

jackfaver 2003-01-30 11:08:29
大侠们能否提供一个复合条件搜索的例子和源程序
即:搜索既满足a又满足b的搜索代码(对应access数据库)
...全文
21 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
j6688j 2003-03-02
  • 打赏
  • 举报
回复
你的用法没问题! or 是表示“或“ and 是 “与“! 就看你想怎么用了,举个例子
a:12354
b:12556
c:34182
如果你想搜索,a b c 都满足的条件 如含 1 2
如果你想搜索,a b c 任意那个满足的条件 如含 1 2 3 4 5 6 8
xjzjgydx 2003-01-31
  • 打赏
  • 举报
回复
up
jackfaver 2003-01-30
  • 打赏
  • 举报
回复
如要实现多字段同内容查询是
select * from 表 where 字段1 like '%"&keyword&"%' and 字段2 like '%"&keyword&"%'
还是
select * from 表 where 字段1 like '%"&keyword&"%' or 字段2 like '%"&keyword&"%'
不同字段不同内容
同上 是用 or 还是 and ??
m1_1m 2003-01-30
  • 打赏
  • 举报
回复
a=trim(request.form("a"))
b=trim(request.form("b"))
sql="select * from tablename where abc like '%"&a&"%' and abc like '%"&b&"%'"
ShiningstarHu 2003-01-30
  • 打赏
  • 举报
回复
<%
Dim db
Dim ConnectionString
Dim rs
Dim strKeywords



'更改数据库名字

db="../../database/db_survey.mdb"

ConnectionString ="DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath(db)

strKeywords = Request.Form("keyword")

Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open "Select * From TB_TABLE1 Where Name Like '%" & strKeywords & "%' Or Function Like '%" & strKeywords & "%'",ConnectionString,3,1

%>
arclala 2003-01-30
  • 打赏
  • 举报
回复
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from tb where item like '%"&request("a")&"%' and '%"&request("b")&"%'"
rs.open sql,conn,1,1
xjzjgydx 2003-01-30
  • 打赏
  • 举报
回复
up
jackfaver 2003-01-30
  • 打赏
  • 举报
回复
顶一下

28,391

社区成员

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

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