Answers To Exercises: Pattern Matching with SQL

Question #1

Find all Employees that have marketing in their title

SELECT NationalIDNumber,
       JobTitle
From   HumanResources.Employee
Where  JobTitle like '%Marketing%'

Question #2

Select all addresses that are on drives.

SELECT AddressID,
       AddressLine1,
       City
 FROM  Person.Address
WHERE  AddressLine1 LIKE '%Dr.'
       OR Addressline1 LIKE '%Drive'

Question #3

Select all products whose product number’s numeric portion starts with 7.  Hint – The product number’s format is AA-9999

SELECT ProductID,
       Name,
       ProductNumber
FROM   Production.Product
WHERE  ProductNumber LIKE '__-7___'
>