Split 程序代碼
復制代碼 代碼如下:
<%attribs="商場名^^快餐店名^^報停名"
names=Split(attribs,"^^")
i=0
for each name in names
response.write names(i)&"<br>"
i=i+1
next
%>
程序拆分結果:
商場名
快餐店名
報停名
根據 Split 結果生成 SQL 語句
復制代碼 代碼如下:
<%attribs="商場名^^快餐店名^^報停名"
names=Split(attribs,"^^")
i=0
sql="select top 10 * from TableName where"
for each name in names
if names(i)="商場名" then
sql=sql+" or 商場 like '%"&names(i)&"%'"
end if
if names(i)="快餐店名" then
sql=sql+" or 快餐店 like '%"&names(i)&"%'"
end if
if names(i)="報停名" then
sql=sql+" or 快餐店 like '%"&names(i)&"%'"
end if
i=i+1
next
sql=sql+" Ordey by Id DESC"
sql=Replace(sql, "where or", "where")
response.write sql
%>
程序運行結果:
復制代碼 代碼如下:
select top 10 * from TableName where 商場 like '%商場名%' or 快餐店 like '%快餐店名%' or 快餐店 like '%報停名%' Ordey by Id DESC