Page 2 of 10PREVNEXT

Queries VI: Use wildcards in queries and parameters

Types of wildcard characters

You use wildcards in your queries when you know only part of a value. For example, say you need to find the engineers in your company, but not everyone is called simply "engineer". The titles might be Engineer II, Quality Engineer, and so on. To find all instances of "engineer" you can use wildcards.

Wildcards can also help you retrieve data that matches a pattern. For example, you can find everyone on the 1000 block of Park Street.

Let's start by looking at the wildcard characters Access provides, and what those characters do.

Callout 1 The asterisk (*) finds any characters located before, after, or inside of a criteria that you specify. The picture shows you one way to use it.
Callout 2 The question mark (?) matches any single alphabetic character.
Callout 3 Square brackets ([]) allow you to be more selective than the question mark. Your result set will include any characters you place inside the brackets.
Callout 4 The exclamation point (!) tells a query to ignore any characters enclosed in brackets.
Callout 5 The dash (-) matches a range of characters. Remember to specify your characters in ascending order — from A to Z, not Z to A.
Callout 6 The number or pound sign (#) matches any single numeric character.

The rest of this course shows you how to match these wildcard characters. Remember that you use a different set of wildcards when you query a Microsoft SQL Server database, and the Quick Reference Card at the end of this course provides a list of those characters.

Page 2 of 10PREVNEXT