Microsoft KB Archive/88166

= ACC: Like vs. = with Wildcard Characters in Query Searches =

Article ID: 88166

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q88166



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



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 <> operator, 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

=&quot;Foos*&quot;

your query will return:

Foos*

But, if your criteria is

Like &quot;Foos*&quot;

your query will return the following four records:

Foos

Foosball

Foos ball

Foos*

The SQL statements built by Microsoft Access for these queries are as follows.

The SQL statement using Like is:

SELECT DISTINCTROW tablename.Col_Name

FROM [tablename]

WHERE ((tablename.Col_Name Like &quot;foos*&quot;));

The SQL statement using = is:

SELECT DISTINCTROW tablename.Col_Name

FROM [tablename]

WHERE ((tablename.Col_Name=&quot;foos*&quot;));

Keywords: kbinfo kbusage KB88166

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.