Skip to content
Advertisement

Dynamic LIKE clause or something like LIKE IN

I have requirement like below:

There are two tables i)TB_VALUES and ii)TB_KEYWORDS.

Here are some sample data for

TB_VALUES:

ID Description
00001 Oracle is better than SQL Server
00001 Python is good
00001 Why should we use oracle
00002 pl/sql guidelines
00002 python tutorial

TB_KEYWORDS:

ID Keywords
00001 Oracle
00001 SQL
00002 SQL

We have to now find the data from TB_VALUES , the Description of those data should contain the keyword. That means for 00001 the description should contain “SQL” or “Oracle” (case insensitive) and for 00002 the description should contain “SQL“(case insensitive) . Our output should be like this :

ID Description
00001 Oracle is better than SQL Server
00001 Why should we use oracle
00002 pl/sql guidelines

For that we have to write something like this:

But I want to do it dynamically.

I can achieve this in PL/SQL but I want output as a view.

Advertisement

Answer

Join + INSTR might help.


If it were a view (as you mentioned), then – based on those tables – it might look like this:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement