用AND可以实现复合搜索,用OR可以实现单独多结果搜索. 文本框中的值——text set rs=server.createobject("adodb.recordset") aa=split(request.form("text")," ") for i=0 to ubound(aa) sql="select * from yourtable where keywords like '%"&aa(i)&"%'" rs.open sql,conn,1,1 ....... rs.close next
实践中需要用多个like
sql="select * from yourtable where keywords like '%"&aa(0)&"%'" and keywords like '%"&aa(1)&"%'" and ...
分开写比较清楚,像这样,呵呵 我经常这么写。 strsql="select * from studentinfo where enrollment<>''" if bianhao<>"" then strsql=strsql & " and (enrollment like '%" & bianhao & "%')" end if if chepaihao<>"" then strsql=strsql & " and (studentnum like '" & chepaihao & "')" end if if danwei<>"" then strsql=strsql & " and (birthday like '" & danwei & "')" end if