Home Privacy Policy Feedback Link to us Site Map Forums

Access: LIKE Condition (using wildcards) in Access 2007


Also learn how to use the LIKE Condition in Access 2003/XP/2000/97.

The LIKE condition allows you to use wildcards in the where clause of an SQL statement in in Access 2007. This allows you to perform pattern matching. The LIKE condition can be used in any valid SQL statement - select, insert, update, or delete.

The patterns that you can choose from are:

* allows you to match any string of any length (including zero length)

? allows you to match on a single character

# allows you to match on a single numeric digit


For example:

Like 'm*' would return all values that start with m
Like '*m*' would return all values that contain m
Like '*m' would return all values that end with m
Like 'm?' would return all values that start with m and are 2 characters in length
Like 'm#' would return all values that start with m and are 2 characters in length where the second character is a number

Here is an example of how you'd use the LIKE condition in a query:

In this example, we are looking for all employee last names that start with "m".


Combining the LIKE condition with the NOT operator

You can also combine the LIKE condition with the NOT operator.

For example:

Not Like 'm*' would return all values that do not start with m
Not Like '*m*' would return all values that do not contain m
Not Like '*m' would return all values that do not end with m
Not Like 'm?' would return all values that are not 2 characters in length starting with m
Not Like 'm#' would return all values that are not 2 characters in length that start m and where the second character is a number

Here is an example of how you'd use the NOT LIKE condition in a query:

In this example, we are looking for all employee last names that do not start with "m".