Reputation: 1
I have two tables: one containing a column (Description) that I would like to search using values in a column (keyword) in another table. I would like to perform something like
select table1.description, tabl2.keyword,
case when
table1.description like `'''%'||table2.keyword||'%''' then 1
-- or contains(table1.description, table2.keyword)
else
0
end
as found
from table1, table2
The documentation for Contain function seems to indicate that the search parameter (table2.keyword in my case) has to be a constant (I suspect "like" also has similar constraints).
The error messages I get seem to indicate this constraint.
Is there a solution that I can use?
Upvotes: 0
Views: 101
Reputation: 1269643
You can do it with like
. Your query should work:
select table1.description, tabl2.keyword,
(case when table1.description like '''%'||table2.keyword||'%'''
then 1 else 0
end) as found
from table1 cross join table2;
I prefer explicit joins, cross join
instead of ,
.
Upvotes: 1