if 语句嵌套
来源:百度知道 编辑:UC知道 时间:2024/05/14 16:15:45
这是我写的个两个条件查询的IF 嵌套语句
whcd 查询可以出来,但是zzmm 这个条件搞不好
我的if 语句嵌套 不会用,大家帮我改改
<%
dim whcd,zzmm
whcd=trim(request.form("whcd"))
zzmm=trim(request.form("zzmm"))
%
<%
set rs=server.CreateObject("adodb.recordset")
if whcd="" and zzmm="" then
rs.open "select * from xxxx ",conn,1,1
else
if zzmm <> "" then
rs.open "select * from xxxx where zzmm="&zzmm , conn,1,1
end if
if whcd <> "" then
rs.open "select * from xxxx where whcd="&whcd , conn,1,1
end if
if zzmm <> "" and whcd <> "" then
rs.open "select * from xxxx where zzmm="&zzmm&" and whcd="&whcd,conn,1,1
end if
end if
%>
whcd 查询可以出来,但是zzmm 这个条件搞不好
我的if 语句嵌套 不会用,大家帮我改改
<%
dim whcd,zzmm
whcd=trim(request.form("whcd"))
zzmm=trim(request.form("zzmm"))
%
<%
set rs=server.CreateObject("adodb.recordset")
if whcd="" and zzmm="" then
rs.open "select * from xxxx ",conn,1,1
else
if zzmm <> "" then
rs.open "select * from xxxx where zzmm="&zzmm , conn,1,1
end if
if whcd <> "" then
rs.open "select * from xxxx where whcd="&whcd , conn,1,1
end if
if zzmm <> "" and whcd <> "" then
rs.open "select * from xxxx where zzmm="&zzmm&" and whcd="&whcd,conn,1,1
end if
end if
%>
<%
dim whcd,zzmm
whcd=trim(request.form("whcd"))
zzmm=trim(request.form("zzmm"))
dim cond
cond = " 1 "
if whcd <>"" then
cond = cond & " and whcd='" &whcd& "' "
end if
if zzmm<>"" then
cond = cond & " and zzmm='" &zzmm& "' "
end if
rs.open "select * from xxxx where "&cond ,conn,1,1