Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Conditional exists in pure SQL.

698658Jul 27 2011 — edited Jul 27 2011
Hi,
I'm on 10.2.0.3 and got problem like this
create table big (id number , words varchar2(22));
insert into big values (1, 'aaa');
insert into big values (1, 'abc');
insert into big values (1, 'bbb');
insert into big values (1, 'ccc');
insert into big values(2, 'eee');

select * from big;

        ID WORDS
---------- ----------------------
         1 aaa
         1 abc
         1 bbb
         1 ccc
         2 eee

		 
		 create table dic1 (data varchar2(22));
		  insert into dic1 values('aaa');
		  insert into dic1 values('bbb');
		 
		 create table dic2 (data varchar2(22));
		 insert into dic2 values('eee');
		 
		 
		 
		 SQL> select * from dic1;

DATA
----------------------
aaa
bbb

SQL> select * from dic2;

DATA
----------------------
eee




select * from big
where
exists (select null from dic1 where instr(words,data) > 0);
Now I want to compare big table with dic2 as well but only if column id from table big equals (id = 2) .
So I need kind of case statement with two exists subquery :
1- for dict1 and 2nd for dic2 but only if id = 2 .
Please advice.
Regards
GregG
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 24 2011
Added on Jul 27 2011
4 comments
373 views