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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Search 1

Status
Not open for further replies.

fischadler

Programmer
May 31, 2002
258
MT
I have a database containg some news articles in which I would like to make a word search. I was thinking of doing something like:

"WHERE NewsDetails LIKE '*" & SearchWord & "*';"

This should bring up all the records containing the SearchWord.
Is there a way to know how many times the search word occurs in each record and possibly sort the recordset by this value?
 
I've wondered about that, too. I hope someone here has an idea.

My preliminary thoughts on it were to join the table to itself a few times, where one time you're searching for LIKE %MyWord% and another you're searching for LIKE %MyWord%MyWord%, yet another LIKE %MyWord%MyWord%MyWord%, etc., grouping everything to avoid record repeats and creating an additional field for each select with the number of matches requested (1, 2, 3, etc.), then ordering by that field.

But man, that seems pretty ugly, and I'm sure hoping there's a better way to do it.
 
I just realised that the "LIKE" operator does not work in ASP. It works fine in Access though. I recall having reported the same problem here some time ago because the ame operator did not work in VB.
Now I am using INSTR to find a match, however I have still not tackled the issue of getting a count of the occurances.
 
The like operator does work with ASP, you just need to change the * to a %.

Leslie
 
Thanks Les,
That didn't answer my question but it solved another problem for me.
 
Glad I could help on something, don't have a clue how to solve your original problem though!!

Thanks for the star!

les
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top