queries

M

minnesotagirl

how can i write a query to find results that include any data with only part
of the data in a field? For example, I want to find all records with
customer name of smith, regardless of whether the record lists the name as
smith, bill or smith, william.
 
D

Dirk Goldgar

Stefan Hoffmann said:
Otherwise you may use the LIKE operator:

SELECT *
FROM yourTable
WHERE yourField LIKE 'Smith%'

This query can use an index on your field. If your field may contain Smith
at any position use

WHERE yourField LIKE '%Smith%'


Note that Stefan has given you the SQL-Server-compatible wild card character
'%'. If you are using an .mdb or .accdb file, then this is not the default
wild-card character. In that case, you would use '*' as the wild-card
character instead.
 
D

Dirk Goldgar

minnesotagirl said:
can I use this with a parameter query? How I format it?


For example,

SELECT *
FROM yourTable
WHERE yourField LIKE '*' & [Enter name:] & '*'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top