Using the split () function to generate SQL query statements in ASP
Source: Internet
Author: User
Split Program code
<%attribs= "Market Name ^ ^ fast-food restaurant name ^"
Names=split (Attribs, "^^")
I=0
For each name in names
Response.Write Names (i) & "<br>"
I=i+1
Next%>
Program Split Result:
Store Name
Snack Bar Name
Name of the newspaper stop
Generate SQL statement based on Split result
<%attribs= "Market Name ^ ^ fast-food restaurant name ^"
Names=split (Attribs, "^^")
I=0
Sql= "SELECT Top * from tablename where"
For each name in names
If names (i) = "Mall name" then
Sql=sql+ "or arcade like '%" &names (i) & "%"
End If
If names (i) = "Snack Bar name" then
sql=sql+ "or fast food like '%" &names (i) & "%"
End If
If names (i) = "Newspaper Stop name" then
sql=sql+ "or fast food 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 Run Result:
Select Top * FROM TableName where arcade like '% Shop name% ' or fast food restaurant like '% fast food restaurant name% ' or fast food '% ' Ordey by Id DESC
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service