|
比如说,我搜索时输入的关键字是"CC AA BB",那么,在输出结果的时候,要求先输出包含CC的,然后输出包含AA的,最后是包含BB的,,就是说是按输入关键字的先后顺序来排序,这样子如何实现?
我用的是ACCESS,下面是我现在搜索用的代码:
keyword=request.Form("keyword")
keyword=Ltrim(Rtrim(keyword))
if instr(keyword," ")<>0 then
str = split(keyword," ")
for i=0 to ubound(str)
if i=0 then
sqlstr = sqlstr&" [a] like '%"&str(i)&"%'"
else
sqlstr = sqlstr&" or [a] like '%"&str(i)&"%'"
end if
next
sqlstr="select * from pros where "&sqlstr
sqlstr =sqlstr & " order by id "
else
sqlstr="select * from pros "
sqlstr = sqlstr & " where [a] like '%" & keyword & "%' "
sqlstr =sqlstr & " order by id "
end if |
|