Query several fields in one table

  • Thread starter Thread starter BSM dbaser
  • Start date Start date
B

BSM dbaser

Hello,
Sometimes the things i think should be simplest really stump me. I want
to query a phone table by number rather than name and the fields are
home, office, pager, cell... etc. How do I build the query for when i
get the question, "who's number is...."?

thank you
 
Hello,
Sometimes the things i think should be simplest really stump me. I want
to query a phone table by number rather than name and the fields are
home, office, pager, cell... etc. How do I build the query for when i
get the question, "who's number is...."?

This table structure may benefit from a redesign: if you have a one to
many relationship between people and phone numbers (as so many of us
do these days!) you may want to split this out to a Phone table with
fields PersonID, PhoneType and PhoneNumber.

Failing that, use OR logic in a Query. Put a criterion

[Enter phone number:]

under *each* of your Phone fields, on separate lines in the query
grid. The SQL will have something like

WHERE [home] = [Enter phone number:] OR [office] = [Enter phone
number:] OR [cell] = [...

and the search will return the record if any of them matches.
 
Back
Top