March 2001
Intermediate to advanced
640 pages
14h 9m
English
So far, you have been able to do simple string comparisons. But when working with strings, you will often need to search patterns within strings. To do that, you will need wildcard characters.
SQL supports two basic wildcard characters:
The percent sign (%) stands for any number of characters (or no characters).
The underscore (_) stands for any single character.
Let's see a few examples.
In an earlier query, we searched for the value 'Tofu' with an equality condition. Let's repeat that query, but change the condition to look for anything starting with 'T'. I'll use the % wildcard and the LIKE keyword:
select ProductName, UnitPrice from Products where ProductName like 'T%'
Results:
ProductName UnitPrice ---------------------------------------- ...
Read now
Unlock full access