asp编写的sql查询语句
把这些做成一个变量来组织SQL语句就行了
sql="select * from tablename where 1=1"
if bookname<>"" then
sql=sql & " and 书名 like '%" & bookname & "'%"
end if
if author <>"" then
sql=sql & " and 作者 like '%" & author & "'%"
end if
if publish <>"" then
sql=sql & " and 出版社 like '%" & publish & "'%"
end if
像这样就可以组织SQL语句了,如果你每次只查询一样,那你可以把字段名和值都作为参数传过来
typ=request("typ")
bookname=request("bookname")
sql="select * from tablename where 1=1"
if typ<>"" then
sql=sql & " and " & typ & " like '%" & bookname & "'%"
end if
留言区(共0条)