After an article:
Where you can use the following between, like, in operator.
Between ... and
Between ... and determines whether the value of an expression falls within the specified range. The syntax is:
Expr Between value1 and value2
Indicates that if the value of expr is between value1 and value2, then between ... The AND operator returns TRUE, otherwise it returns false.
You can also add the logical operation not expr Between value1 and value2 to determine the opposite condition that expr falls outside the scope of value1 and value 2.
If expr, value1, or value2 is null, between ... and returns a null value.
You can't be in Between ... Wildcard * is used in the and operator, for example, you cannot use 100* and 500* to find the product code between 1000 and 5000.
Like
Like looking for matching keywords.
Like follows a formula that lists the strings or string literals to be compared.
In an expression, you can use the LIKE operator to compare a field data with a string expression. You can use the wildcard character * to find similar data, such as "Wang *", and the query will return all the fields with the [King] as the beginning of the data.
Symbols that the like post expression can use:
%: Wildcard, representing one or more characters, such as like jack% will find all the string words that start with Jack, like%jack% to find the string of words including Jack.
_: A character wildcard, such as like Jack_ will find such as Jack1, Jacka and other strings of text, like _jack_ to find such as AJACKB, CJACKF, and other strings of text.
[X-y]: Specify a range of characters, such as like [A-c]jack will find string text such as Ajack1, Bjack, Cjack, and so on.
[^x-y]: Specifies the excluded character range, for example, like [^a-c]jack will not find string literals such as Ajack1, Bjack, Cjack, and so on.
In the following example, you get information about any letter and a number that starts with the letter A and then follows between B and G:
Like "a[b-g]#"
In
In expression, limited scope.
The syntax is:
expr [not] in (value1, value2,...)
Where expr is an expression field. Value1, value2, ... To the specified range list.
For example, you can use the in operator to specify the city in which the student must reside, for Guangzhou, Shenzhen, or Shantou:
SELECT *
From students
WHERE City in (' Guangzhou ', ' Shenzhen ', ' Shantou ')
Let's look at an example of an ASP program using this SQL directive.
We can use the IN clause to determine the scope, such as the ASP program rs24.asp as follows, [select Name, account, score from test where score in (SELECT score from Test where score >=60)], use in to find the score greater than or equal to 60 Minutes of records:
<%
Set conn1 = Server.CreateObject ("ADODB. Connection ")
Conn1. Open "dbq=" & Server.MapPath ("Ntopsamp.mdb") & ";D river={microsoft Access Driver (*.mdb)};D riverid=25;fil=ms Access; "
Set rs2 = Server.CreateObject ("ADODB. Recordset ")
sqlstr = "Select name, account, score from test where score in (select fraction from test where score >=60)"
Rs2. Open sqlstr,conn1,1,1
Response.Write "<p>in: Less than 60 points"
Do as not rs2. Eof
Response.Write "<BR>" & Rs2 ("name") & "& Rs2 (" Account ") &" Score: "& Rs2 (" Score ")
Rs2. MoveNext
Loop
Rs2. Close
%>
The above ASP program rs24.asp, uses the browser in the client side, browses the execution result, displays the score is greater than or equal to 60 minutes record.
Not in
Not in expression that does not belong to the specified range.
Let's look at an example of using this SQL instruction in an ASP program.
We can use the NOT IN clause to determine the records that should not be displayed, such as the ASP program rs24.asp as follows, [select Name, account, score from test where to score not in (SELECT score from Test where score >=60)], use In to find records that are not greater than or equal to 60 points, i.e. records less than 60 points:
<%
Set conn1 = Server.CreateObject ("ADODB. Connection ")
Conn1. Open "dbq=" & Server.MapPath ("Ntopsamp.mdb") & ";D river={microsoft Access Driver (*.mdb)};D riverid=25;fil=ms Access; "
Set rs2 = Server.CreateObject ("ADODB. Recordset ")
sqlstr = "Select name, account, score from test where fraction not in (select fraction from test where score >=60)"
Rs2. Open sqlstr,conn1,1,1
Response.Write "<p>not in: above 60 points not counted"
Do as not rs2. Eof
Response.Write "<BR>" & Rs2 ("name") & "& Rs2 (" Account ") &" Score: "& Rs2 (" Score ")
Rs2. MoveNext
Loop
Rs2. Close
%>
The above ASP program rs24.asp, uses the browser in the client side, browses the execution result, displays the score not more than or is equal to 60 points record