WHERE clause with variable-length wildcard
The statements in the following query use a wildcard at
the end of a string to retrieve all the rows where the description begins
with the characters
bicycle
. Either statement returns the following rows.
The comparison 'bicycle%
' or 'bicycle*
'
specifies the characters bicycle
followed by any
sequence of zero or more characters. It matches bicycle stem
with stem
matched
by the wildcard. It matches to the characters bicycle
alone,
if a row exists with that description.
The following query narrows
the search by adding another comparison condition that excludes a manu_code of
PRC
. The statement retrieves only the following rows.
When you select from a large table and use an initial
wildcard in the comparison string (such as '%cycle
'),
the query often takes longer to execute. Because indexes cannot be
used, every row is searched.