Combine CONTAINS and WHERE queries?

Results 1 to 2 of 2

Thread: Combine CONTAINS and WHERE queries?

  1. #1
    Join Date
    Dec 1969

    Default Combine CONTAINS and WHERE queries?

    What I&#039;m trying to do is build a search function where if the user selects a particular item from a dropdown list called "peo_select" and types in a keyword in another field, it will return all records that contain the value from the peo_select and only if contains the keyword in ANY of the columns in that particular record.<BR><BR>I&#039;m trying to combine a simple SELECT statement but also include a CONTAINS statement which is used from connected to a full-text indexing catalog that I&#039;ve got setup (on SQL Server 2000). Here&#039;s what I&#039;ve got...but it&#039;s just not working right:<BR><BR>strSQL = "SELECT * FROM NNeeds WHERE NNArea LIKE &#039;" & peo_select & "&#039; AND CONTAINS(*, &#039;%" & strKeyword & "%&#039;)<BR><BR>Am I combining these two types of statements correctly or not? How do I write my statement so taht it will look for any matching record with the correct peo_select value...but only return it if it also has the strKeyword in any of the fields???<BR><BR>Help?

  2. #2
    Join Date
    Dec 1969

    Default RE: Combine CONTAINS and WHERE queries?

    look up "contains" it is a word or phrase string...<BR><BR>so for instance you can have <BR> CONTAINS(*, &#039;Bread&#039;) -- looks for word bread<BR>or<BR> CONTAINS(*, &#039;*Bread*&#039;) -- lokks for a word with bread in it.<BR><BR>Also Check you indexes have full-text search on all columns!<BR><BR>Combining like is ok but again Like Must have % in the criteria<BR><BR> Like &#039;Fred%&#039;<BR>or <BR> Like &#039;%Fred%&#039;<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts