user3139937
user3139937

Reputation: 113

SQL string search: indexing one table to another

I am trying to search for particular strings. So instead of putting the keyword on the string itself (ex. select * from report r where Upper (r.summary) like '%FRANK%') , I saved all the words on a table. Now how do you index that keyword table.

Example: 'Frank' is added to "Keywordtable", now I want to see any on the "Report" summary table with the mention of that keyword, "Frank". Is it possible to do?

Just to be more clear

select *
from contact_document r
where Upper (r.summary) like '%CANCER%'

but the keywords are saved on a table with the list of diseases, called "diseasetable"

select m.disease, m.rowid 
from diseasetable m

I wanted to every time i run the script, it will return any contact_document with any of the diseases listed on the diseasetable appearing on r.summary

Upvotes: 0

Views: 41

Answers (1)

shA.t
shA.t

Reputation: 16958

I think you need a query like this:

SELECT *
FROM
    yourTableOfStrings s
  JOIN
    yourTableOfKeywords k
  ON s.string Like CONCAT('%', k.keyword, '%');

[SQL Fiddle Demo]

Upvotes: 1

Related Questions