Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Query Question

Status
Not open for further replies.

webgs

Programmer
Oct 30, 2001
59
US
This may be an easy one for SQL gurus.

I've written a simple search engine with SQL. It works fine when I search on a single term like "test". It does not work when I use more than one term like "run test". Any ides where I should start looking for a fix?



 
How are you doing the search? What would the where clauses look like in the SQL statments bewteen the one which works and the one which doesn't? Are you using full-text search?



Questions about posting. See faq183-874
 
Here is the WHERE clause that works for one term:

WHERE Pages.PageBodyText LIKE '%" & searchstring & "%'

The value for "searchstring" is posted from a form field.

Does that help a little?
 
and what would be the two term search item? Do you want to search for "run", "test", "run test" or just "run test"?

I would consider using fulltext search as a search with like and then a wildcard in the first term automatically means that indexes cannot be used. This means the search will become extremely slow as more records are added.

Questions about posting. See faq183-874
 
Hi There,

I Have a similar question.

I have a asp page that contains a search box. Single word searches work fine. However what i would like to have is the facility to type multiple words into the search box and only have records returned that contain all words entered. I know that I could do this by typing AND into the search box, however this is not very user friendly. Is there any way that I can script the SQL statement to search for all words in the search string, or do I have to do some scripting to add AND where there is a space and then pass that as the search string.

Thanks


Greg Palmer
Freeware Utilities for Windows Administrators.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top