Database Reference
In-Depth Information
Figure 5-10. Using the LIKE operator with [ ]
How It Works
You specify three columns of the Address table.
select AddressID, AddressLine1, City
from Person.Address
You specify the WHERE clause with a pattern using the LIKE operator to list all cities that begin with
the letter B or R or S and consist of any number of letters after that, for example Bellevue, Redmond,
Seattle, and so on.
where City like '[B,R,S]%'
Order by City Asc
Try It: Using the Square Bracket and Caret ([^ ]) Characters
To see how the [^B,R,S] characters work in pattern matching, open a New Query window in SQL Server
Management Studio Express. Enter the following query, and click Execute. You should see the results
shown in Figure 5-11.
Select AddressID, AddressLine1, City
from Person.Address
where City like '[^B,R,S]%'
Order by City Asc
 
Search WWH ::




Custom Search