Databases Reference
In-Depth Information
The query results appear in Figure 3-25.
86
Only customers with
credit limits that exceed
their balances are listed
FIGURE 3-25 Query results
USING SPECIAL OPERATORS (LIKE AND IN )
In most cases, your conditions will involve exact matches, such as finding all customers located in the city of
Sheldon. In some cases, however, exact matches will not work. For example, you might know only that the
desired value contains a certain collection of characters. In such cases, you use the LIKE operator with a wild-
card, as shown in Example 14.
EXAMPLE 14
List the number, name, and complete address of every customer located on a street that contains the letters
Oxford .
All you know is that the addresses that you want contain a certain collection of characters (Oxford) some-
where in the Street field, but you don't know where. In Access SQL, the asterisk (*) is used as a wildcard to rep-
resent any collection of characters. (In MySQL, the percent sign (%) is used as a wildcard to represent any
collection of characters.) To use a wildcard, include the LIKE operator in the WHERE clause. The query design
shown in Figure 3-26 will retrieve information for every customer whose street contains some collection of
characters followed by the letters Oxford , followed potentially by some additional characters.
Wildcards
LIKE operator
FIGURE 3-26 SQL query with a LIKE operator
 
 
Search WWH ::




Custom Search