Part 13 - Return records to
match a text string using LIKE operator
The
LIKE operator searches through text within fields and returns
records that match a text string.
Th above example (Screen shot of Excel 2011) lists all
products from ExampleData.xls that are oil roasted.
To use the LIKE comparison operator, in the Criteria field
type the word like followed by a space then surround the
search characters in single quotes and percent signs as shown.
SELECT Products.ProductName
FROM Products WHERE (Products.ProductName
like '%oil rstd%')
To obtain the records which do not match a string use
not like.
SELECT Products.ProductName FROM Products WHERE
(Products.ProductName not like '%oil rstd%')
To obtain the records which start with a certain string, leave
out the first percent sign %.
SELECT Products.ProductName FROM Products WHERE
(Products.ProductName
like 'sun%')
To obtain the records which end
with a certain string, leave out the final percent sign %.
SELECT Products.ProductName FROM Products WHERE
(Products.ProductName
like '%salt')