Pages

ADSENSE link unit (728 X 15px) SPACE

Countryside Gazebos

Tuesday, September 6, 2011

Retrieving Table Data with the LIKE Operator

How to use the LIKE operator

One final operator you can use in a search condition is the LIKE operator, shown in figure 3-15. You use this operator along with the wildcards shown at the top of this figure to specify the string pattern, or mask, that you want to match. The examples in this figure show how this works.

In the first example, the LIKE phrase specifies that all vendors in cities that start with the letters SAN should be included in the query results. Here, the percent sign (%) indicates that any characters can follow these three letters. So San Diego and Santa Ana are both included in the results.

The second example selects all vendors whose vendor name starts with the letters COMPU, followed by any one character, the letters ER, and any characters after that. Two vendor names that match that pattern are Compuserve and Computerworld.

The LIKE operator provides a powerful technique for finding information in a database that can?t be found using any other technique.

The syntax of the WHERE clause with the LIKE operator

WHERE match_expression [NOT] LIKE pattern

Wildcard symbols

Matches any string of zero or more characters.

WHERE clauses that use the LIKE operator

Results that match the mask the mask

WHERE vendor_name LIKE 'COMPU_ER%'

"Compuserve"and "Computerworld"

Description

You use the LIKE operator to retrieve rows that match a string pattern, called a mask. Within the mask, you can use special characters, called wildcard characters, that determine which values in the column satisfy the condition.
You can use the NOT operator before the LIKE operator. Then, only those rows with values that don?t match the string pattern will be included in the result set. --------------------------------------------Figure 3-15 How to use the LIKE operator


blog comments powered by

Gazebo shed on saleDownload here
» Link to this page:

» Link to Home Page:

1 Responses: Retrieving Table Data with the LIKE Operator

Post a Comment

Powered by Blogger.