Databases Reference
In-Depth Information
Figure 4-8. Using the LIKE operator with %
How It Works
You concatenate the three columns Title, FirstName, and LastName into one column
titled “Person Name” using the + operator as follows:
select Title + ' ' + FirstName + ' ' + LastName
as "Person Name"
You specify the WHERE clause with a pattern using the LIKE operator to list all people
whose first name begins with the letter “A” and consists of any number of letters. You also
specify the condition that the null values from the Title column should not be listed.
where FirstName like 'A%' and Title is not null
Try It Out: Using the _ (Underscore) Character
To see how the _ wildcard character works, 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 4-9.
Search WWH ::




Custom Search