Microsoft KB Archive/209834

= ACC2000: Like vs. Equal to (=) with Wildcard Characters in Query Searches =

Article ID: 209834

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209834



Novice: Requires knowledge of the user interface on single-user computers.

This article applies only to a Microsoft Access database (.mdb).



SUMMARY
When you use wildcards (for example, * or ?) to search for a string, you must use "Like" or "Not Like" in the Criteria field, rather than the Equal to (=) or Not Equal to (<>) operators. When you use the = or <> operators, Microsoft Access treats them as actual characters to search for.



MORE INFORMATION
If you have a table with one column called Col_Name and the following four records

Foos

Foosball

Foos ball

Foos*

and you create a query based on the table with the criteria

="Foos*"

your query returns:

Foos*

But, if your criteria is

Like "Foos*"

your query returns the following four records:

Foos

Foosball

Foos ball

Foos*

The SQL statement using Like for this query is as follows:

SELECT DISTINCTROW tablename.Col_Name FROM [tablename] WHERE ((tablename.Col_Name Like "foos*")); The SQL statement using = for this query is as follows: SELECT DISTINCTROW tablename.Col_Name FROM [tablename] WHERE ((tablename.Col_Name="foos*"));

