ASP多条件查询

来源:百度知道 编辑:UC知道 时间:2024/06/04 11:22:23
数据库四列name,no1,no2,pay
要求查询同时输入前三个选项的内容才可以显示D列的内容
例如:
查询name为张三,no1为222,no2为111,pay为520
要求同时输入三个条件并且符合才可以查询出pay的值,否则提示出错~~

name=request("name")
no1=request("no1")
no2=request("no2")

if name<>"" and no1<>"" and no2<>"" then
sql="select * from 表 where name='"&name&"' and no1='"&no1&"' and no2='"&no2&"'"
else
response.write("完整查询条件后再查询")
end if

conn.execute sql

sql="select * from 表 where name='" & 输入的参数1 & "' and no1='" & 输入的参数2 & "' and no2='" & 输入的参数3 & "'"
rs.open sql,conn,1,1
if rs.eof then
'错误
else
'正确
response.write(rs("pay"))
end if