Using Microsoft Office For Mac as a Relational Database

By Jim Gordon, co-author of Office 2011 for Mac All-in-One For Dummies.

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.

SQL string matching query

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')

Part 1
Part 12 Part 14 (Next)