Question : Query over multiple fields

Hi,

I am needing to writing a query that is able to search for multiple words over multiple fields and only be classed as a match if all the words are found.  For example if i was searching for "blue whale" and I have a table made up from 2 fields called Subject and Description and a subset of data was:-

Row       Subject         Description
1           Blue              Panther
2           Something    else
3           Whale           Blue
4           Blue Whale    Ocean

From this if i search for "blue whale" then I need to match rows 1,3 and 4 even though the words "blue whale" do not necessary appear in the same field.  The databases we use as primarily MS Access so we need a solution that will work with that.

Any help would be much appreicated.

Many Thanks

Chris

Answer : Query over multiple fields

To solve the specific problem you described, you could use:

SELECT Row, Subject, Description
FROM tblBlueWhale
WHERE ((InStr([subject] & " " & [description],"blue")>0 And InStr([subject] & " " & [description],"whale")>0)=True);

However, I suspect you're looking for a more generic solution. How do you intend to supply the words to be searched for?
Random Solutions  
 
programming4us programming4us