Explore BrainMass

SQL pattern matching with MS Access

Why wont this query give me any results?

SELECT author_name
FROM authors
WHERE author_name = "*Twain, Mark*";

After all, the text string

Twain, Mark

does exist in the author_name table.... (try it out using the database "WEEK1_Q1_Q2_ACCESS2000.mdb" attached here.


Solution Preview

This query is a valid query but it's probably not doing what you expect. When searching on text fields there are two ways to search the text. One is an "exact match" and the other is a "pattern match". Using the "=" symbol tells Access to perform an exact match. Using ...

Solution Summary

This solution shows how to do pattern matching in a MS Access SQL query. It explains the difference between an exact match and pattern match string comparison.