create table tab(
id_1 number,
column_1 varchar2(20),
variable_1 varchar2(20))
Table created.
insert into tab(id_1,column_1,variable_1) values(1,'12abc12','abc')
1 row(s) inserted.
insert into tab(id_1,column_1,variable_1) values(2,'EFGSSDK','EFG')
1 row(s) inserted.
insert into tab(id_1,column_1,variable_1) values(3,'efg SDK','EFG')
1 row(s) inserted.
insert into tab(id_1,column_1,variable_1) values(4,'abc 3 8','XYZ')
1 row(s) inserted.
insert into tab(id_1,column_1,variable_1) values(5,'_','XYZ')
1 row(s) inserted.
insert into tab(id_1,column_1,variable_1) values(6,'_','KDG')
1 row(s) inserted.
insert into tab(id_1,column_1,variable_1) values(7,'1 3','KDG')
1 row(s) inserted.
insert into tab(id_1,column_1,variable_1) values(8,'13 efg iu','abc')
1 row(s) inserted.
commit
Statement processed.
select tab.id_1, tab.column_1
from tab
where (variable_1 = 'abc' and column_1 not like '%abc%') or
(variable_1 = 'EFG' and column_1 not like '%efg%') or
(variable_1 = 'XYZ' and column_1 not like '%abc%' and column_1 not like '%efg%') or
(variable_1 not in ('abc', 'EFG', 'XYZ') and column_1 not like '_')
| ID_1 | COLUMN_1 | 2 | EFGSSDK | 5 | _ | 7 | 1 3 | 8 | 13 efg iu |
|---|