Database Reference
In-Depth Information
When used as an SQL wildcard character, the percent symbol (%) stands for any sequence
of characters. When used with the SQL LIKE keyword, the character string 'Pete%' means any
sequence of characters that starts with the letters Pete. The result of this query is:
Does Not Work with
Microsoft access
aNSI-89 SQL
Microsoft Access ANSI-89 SQL uses wild-
cards, but not the SQL-92 standard wildcards.
Microsoft Access uses the Microsoft access
asterisk (*) wildcard character instead of a
percent sign to represent multiple characters.
Solution: Use the Microsoft Access asterisk (*) wildcard in place of the SQL-92 percent
sign (%) wildcard in Microsoft Access ANSI-89 SQL statements. Thus, the preceding
SQL query would be written as follows for Microsoft Access:
/* *** SQL-Query-CH02-21-Access *** */
SELECT *
FROM
SKU_DATA
WHERE
Buyer LIKE 'Pete*';
Suppose we want to find the rows in SKU_DATA for which the SKU_Description includes
the word Tent somewhere in the description. Because the word Tent could be at the front, at the
end, or in the middle, we need to place a wildcard on both ends of the LIKE phrase, as follows:
/* *** SQL-Query-CH02-22 *** */
SELECT *
FROM
SKU_DATA
WHERE
SKU_Description LIKE '%Tent%';
This query will find rows in which the word Tent occurs in any place in the SKU_Description.
The result is:
Sometimes we need to search for a particular value in a particular location in the column.
For example, assume SKU values are coded such that a 2 in the third position from the right
has some particular significance; maybe it means that the product is a variation of another
product. For whatever reason, assume that we need to find all SKUs that have a 2 in the third
column from the right. Suppose we try the SQL query:
/* *** SQL-Query-CH02-23 *** */
SELECT *
FROM
SKU_DATA
WHERE
SKU LIKE '%2%';
 
Search WWH ::




Custom Search