Multi field search

  • Thread starter Thread starter LCalaway
  • Start date Start date
L

LCalaway

Good morning.
Is there a way to construct one query that will search across more than one
field for the same string? If I have two fields, FName and LName and
Example: I want to find all instances of the word string "John" which can
appear in either or both fields, in the same or different records. The
query needs to return each of the following records in its answer:
John Johnson
Harry Johnson
John Dickson
Thank you.
LCalaway
 
LCalaway said:
Good morning.
Is there a way to construct one query that will search across more
than one field for the same string? If I have two fields, FName and
LName and Example: I want to find all instances of the word string
"John" which can appear in either or both fields, in the same or
different records. The query needs to return each of the following
records in its answer:
John Johnson
Harry Johnson
John Dickson
Thank you.
LCalaway

SELECT * FROM SomeTable
WHERE FName Like "*John*"
OR LName Like "*John*"

In the query design grid you would simply put the two criteria on separate rows
to achieve the OR.
 
Rick Brandt said:
SELECT * FROM SomeTable
WHERE FName Like "*John*"
OR LName Like "*John*"

In the query design grid you would simply put the two criteria on separate
rows to achieve the OR.


Note that if you want to be prompted for your search term, you can use

SELECT * FROM SomeTable
WHERE FName Like "*" & [What name?] & "*"
OR LName Like "*" & [What name?] & "*"

As long as you type exactly the same parameter name ([What name?]) above,
you'll only be prompted once.
 
Back
Top