A “wildcard”
is a special symbol that takes the place of a unknown character or set
of characters—it is used in criteria in order to match several items.
In Access queries, wildcards are used with the special operator Like, which indicates that instead of an exact match, you’re looking to match items that fit a certain pattern. The pattern is stated by using wildcards. Like statements always take the form:
Like “<<criteria with wildcards>>”
Where the criteria with wildcards are enclosed in “double-quotes”.
Wildcards:
Wildcards used in Access include:
* (the asterisk): matches any number of characters (including zero characters!)
? (the question mark): matches exactly one character
[a-l] : matches any letter from a to l. (In Access, this is NOT case-sensitive.)
[a,d,l] : matches the letter a, the letter d, or the letter l. (In Access, this is NOT case-sensitive)
Examples:
Criteria Statement
|
Matches
|
Like “*”
|
Anything
|
Like “B*”
|
Anything that begins with B, e.g. Bob, Bill, B, Breakfast
|
Like “*red”
|
Anything that ends with red, e.g. tired, Fred, red, Winnifred
|
Like “1/1/*” (for a date field)
|
Dates on January 1st of any year
|
Like “C??”
|
Any three letter word starting with c, e.g. cat, car, cot. Each match MUST have three letters.
|
Like “[a-c]*”
|
Anything that begins with A, B, or C, e.g. Acrobat, Bottle, Chant
|
Like “[d,l]*”
|
Anything that begins with D or L, e.g. Donut, Lake, Discount
|