Sometimes we need to implement multiple condition queries based on parameters. Here we use the split function to split the parameters into multiple
Split program code
Copy the code code as follows:
<%attribs="Shopping mall name^^fast food restaurant name^^report suspension"
names=Split(attribs,"^^")
i=0
for each name in names
response.write names(i)&"<br>"
i=i+1
next
%>
Program split results:
Mall name
fast food restaurant name
Report suspension
Generate SQL statements based on Split results
Copy the code code as follows:
<%attribs="Shopping mall name^^fast food restaurant name^^report suspension"
names=Split(attribs,"^^")
i=0
sql="select top 10 * from TableName where"
for each name in names
if names(i)="Mall name" then
sql=sql+" or shopping mall like '%"&names(i)&"%'"
end if
if names(i)="Fast food restaurant name" then
sql=sql+" or fast food restaurant like '%"&names(i)&"%'"
end if
if names(i)="Report name suspension" then
sql=sql+" or fast food restaurant like '%"&names(i)&"%'"
end if
i=i+1
next
sql=sql+"Ordey by Id DESC"
sql=Replace(sql, "where or", "where")
response.write sql
%>
Program running results:
Copy the code code as follows:
select top 10 * from TableName where shopping mall like '%shopping mall name%' or fast food restaurant like '%fast food restaurant name%' or fast food restaurant like '% report suspension name%' Ordey by Id DESC