多条件查询
作者:cmscn 日期:2008-08-11
sql="select * from user where"
if username<>"" then
sql=sql&" username like'%"&username&"%'"
flag=1
elseif tel<>"" and flag=1 then
sql=sql&" and tel like '%"&tel&"%'"
flag=1
elseif tel<>"" then
sql=sql&" tel like '%"&tel&"%'"
elseif shool<>"" and flag=1 then
sql=sql&" and shool like '%"&shool&"%'"
flag=1
elseif shool<>"" then
sql=sql&" shool like '%"&shool&"%'"
end if
if flag<>1 then
sql="select * from user order by id desc "
end if
rs.open sql,conn,1,1
if rs.eof or rs.bof then
response.write "没有符合的记录!"
else
do while not rs.eof
response.write "username:"&rs("username")&"<br>"
response.write "tel:"&rs("tel")&"<br>"
response.write "shool:"& rs("shool")&"<br>"
rs.movenext
loop
end if
评论: 0 | 引用: 0 | 查看次数: 406
发表评论