aspose file tools*
The moose likes JDBC and the fly likes Word by word string matching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Word by word string matching" Watch "Word by word string matching" New topic
Author

Word by word string matching

Rekha Pande
Ranch Hand

Joined: Jan 29, 2004
Posts: 145
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

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Jan 29, 2004
Posts: 145
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

Joined: Jan 29, 2004
Posts: 145
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

Joined: Aug 15, 2004
Posts: 2874
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Word by word string matching
 
Similar Threads
please help me about EJB-QL......
need help in EJB QL with upper and like
Problem Named Queries In Hibernate
stuck up in the problem
In clause in oracle