asp sql 查询...急 在线等...

来源:百度知道 编辑:UC知道 时间:2024/05/30 07:09:40
<%
dim rs,sql,key
Key1=request.form("j_jb")
Key2=request.form("j_zcd")
Key3=request.form("j_xj")
'sql="select * from jzstm"
sql="select * from jzstm where j_name like '%"&Key1 &"%' and j_jb like '%"& Key2&"%'and j_jb like '%"&Key3&"%'"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.eof and rs.bof then
response.Write "没搜索到相关信息"
else
while not rs.eof
%>
<tr bgcolor="#FFFFFF" class="text">
<td height="22" align="center"><%=rs("j_name")%></td>
<td height="22"><%=rs("j_number")%></td>
<td height="22" align="center"><%=rs("j_jb")%> </td>

看看你自己SQL语句`~~
sql="select * from jzstm where j_name like '%"&Key1 &"%' and j_jb like '%"& Key2&"%'and j_jb like '%"&Key3&"%'"

后面两个条件
and j_jb like '%"& Key2&"%'and j_jb like '%"&Key3&"%'
两个条件查询同一个字段,但是值不一样`~~你确定这一个字段包含Key2和Key3的内容么???

你的数据表中是否有j_zcd,j_xj这两个字段???
将Key2和Key3对应上,换个字段查询就行了`~~
如果没有这两个字段的话就把SQL语句改成`~如下两种情况`~
sql="select * from jzstm where j_name like '%"&Key1 &"%' and j_jb like '%"& Key2&"%'"
或者
sql="select * from jzstm where j_name like '%"&Key1 &"%' and (j_jb like '%"& Key2&"%'or j_jb like '%"&Key3&"%')"

select * from jzstm where j_name like '%"&Key1 &"%' and j_jb like '%"& Key2&"%'and j_jb like '%"&Key3&"%'"

上面这句 j_jb like Ke