Databases Reference
In-Depth Information
The query results appear in Figure 3-27.
87
Customer
whose street
contains Oxford
FIGURE 3-27 Query results
Another wildcard in Access SQL is the question mark (?), which represents any individual character. For
example, “T?m” represents the letter T followed by any single character, followed by the letter m and would
retrieve records that include the words Tim , Tom ,or T3m , for example. Many versions of SQL, including
MySQL, use the underscore (_) instead of the question mark to represent any individual character.
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 Credit
Limit = 10000 OR CreditLimit = 15000. The approach shown in Figure 3-28 is simpler, however—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.
IN operator
List of values
FIGURE 3-28 SQL query with an IN operator
 
Search WWH ::




Custom Search