<%
dim sql
dim email1
dim email2
dim email3
dim email4
sql="SELECT e.ID FROM customer_email INNER JOIN e ON customer_email.customer_id = e.ID WHERE "
email1=request.form("email1")
email2=request.form("email2")
email3=request.form("email3")
email4=request.form("email4")
if email1<>"" then
sql=sql+" customer_email like '%"&trim(email1)&"%'"
end if
if email2<>"" then
if len(sql)=91 then
sql=sql+" customer_email like '*"&email2&"*'"
else
sql=sql+" and customer_email like '*"&email2&"*'"
end if
end if
if email3<>"" then
if len(sql)=91 then
sql=sql+" customer_email like '*"&email3&"*'"
else
sql=sql+" and customer_email like '*"&email3&"*'"
end if
end if
if email4<>"" then
if len(sql)=91 then
sql=sql+" customer_email like '%"&email4&"%'"
else
sql=sql+" and customer_email like '%"&email4&"%'"
end if
end if
sql=sql+" GROUP BY e.ID "
set rs=server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,3
if rs.eof then
response.write "<script>alert('没有你所查的资料!\n\n返回!');history.back();"
response.write "</script>"
response.end()
end if
应该没有问题啊,我导入到SQL SERVER 里面在用这个语句是可以的啊