• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Word by word string matching

 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..

I am trying to search for matching string using the like operator.
String 1: Training request
String 2: Required Training

If i use the sql query:
"Select * from <table name> where <coloum name> LIKE '%Training%'"

.. then i get both the string results mentioned above...

but if i use the sql query:
"Select * from <table name> where <coloum name> LIKE '%Training In What%'"

... I get an empty set.

Can please some one tell me how i can do a word by word string matching so that my sql query searches for 'Training ', 'In', 'What' as 3 seprates words and gives me the 2 strings mentioned above.

Please help.

Thanxs
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assuming that the input string is from the user. you can ask the user whether he/she wants to search the full exact phrase or any of the word. then you can make your query dynamically.
 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah that's what im looking for. What is the sql query that i would be using so that any of the words in the sql string will be used for searching purpose.

Please help
Thanxs
 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i have got the answer to find word matching from the entire string using FULLTEXT in an SQL Query.

But now can please some one tell me... how can i make the related words highlighted. Like in yahoo... the matching words are highlighted. Can please some one guide me on to it..!!!

Thanxs
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you just use like operator in different ways for the query stuff.

like "%what%"
like "%training%"
like "%in%"
like "%where%"

though you have got the solution for full length text search. you can use somehting like "what in training" as well.

i think your other question is not relevent to jsp, although even your first question was not jsp question . you should post it in html forum now.

cheers
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic