Database Reference
In-Depth Information
The query results appear in Figure 3-28.
89
Customer
whose street
contains Oxford
FIGURE 3-28
Query results
Another wildcard in Access SQL is the question mark (?), which represents any individual character. For
example,
represents the letter T followed by any single character, followed by the letter m and when
used in a WHERE clause, retrieves records that include the words Tim, Tom,orT3m, for example. Many
versions of SQL, including MySQL, use an underscore (_) instead of the question mark to represent any indi-
vidual character.
T?m
NOTE
In a large database, you should use wildcards only when absolutely necessary. Searches involving wildcards can be extremely
slow to process.
Another operator, IN, provides a concise way of phrasing certain conditions, as Example 15 illustrates.
EXAMPLE 15
List the number, name, street, and credit limit for every customer with a credit limit of $7,500, $10,000, or
$15,000.
In this query, you can use the SQL IN operator to determine whether a credit limit is $7,500, $10,000,
or $15,000. You can obtain the same result by using the condition WHERE CreditLimit
7500 OR
¼
CreditLimit
the
IN clause contains the collection of values 7500, 10000, and 15000. The condition is true for those rows in
which the value in the CreditLimit column is in this collection of values.
10000 OR CreditLimit
15000. The approach shown in Figure 3-29 is simpler, however
¼
¼
IN operator
List of values
FIGURE 3-29
SQL query with an IN operator
Search WWH ::




Custom Search