目的:記事表の記事キーワードをクエリします
クエリ形式:Baidu Google Baiduの方が優れているか、Googleの方が良いBaidu + Google(条件を入力せずにクエリもできます)
<! - #includefile = "conn.asp" - >
<%
functionsearshsql(tname、lname、str) 'tname-table namelname-column namestr-query文字
iftrim(str)= "" then
mysql = "select*from"&tname
それ以外
str = sqlencode(str) 'プリプロシングクエリ文字列
arrstr = split(str、 "") '文字列はスペースで処理されます
umax = ubound(arrst) 'セグメンテーション後、配列が分割され、分割されたキーワードの数が決まります
ifumax> 0then 'キーワード内の複数のスペースの処理 "ifumax> 0then"は2番目の次元から始まります
fori = 1toumax
strtemp = arrstr(i)
iftrim(strtemp)= "" thenstrtemp = "/~~~~~/" '分割された要素は空で、特殊文字に置き換えられます。
sql = sql& "または"&lname& "like '%"&strtemp& "%'"
次
endif
mysql = "select*from"&tname& "where"&lname& "like '%"&arrst(0)& "%'"&sql
する
j = strust(1、mysql、 "%/~~~~~/%"、1)
ifj = 0then
出口
endif
mysql = cheplage(mysql、 "or"&lname& "like '%/~~~~/%'"、 "")