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!

Retrn result only if both conditions are true

450482Feb 14 2008 — edited Feb 15 2008
I have this query to get list of names that are associated with
a keyword called 123 but do not belong to a item named 456


select distinct t1.lname, t1.sname , t5.rname
from table1 t1, table2 t2, tale3 t3,
table4 t4, table5 t5,
TABLE(xmlsequence(extract(t4.xmlcol,'/cs/lo/c'))) k
where t1.id = a.id
and t3.id = a.id
and t4.id = t3.id
and t5.id = t3.id


<--1st condition -->

and extractValue(k.column_value,'c/L/keyword/@id') in ('123')

<-- 2nd conditon-->
and t5.item not in (select distinct t6.name from table7 t7, table6 t6

where t7.id= t6.id
and t6.ref_id = 456)


In my database, I have 2 names. for a
given lname in the output, it is associated
with 2 rnames.One rname is associated with
keyword 123 and the other rname is associated
with item 456. Something like this:
lname &nbsp; sname &nbsp; rname
jakal &nbsp;&nbsp;&nbsp; jkl &nbsp;&nbsp;&nbsp;&nbsp; r123 --> associated with keyword 123
jakal &nbsp;&nbsp;&nbsp;&nbsp; jkl &nbsp;&nbsp;&nbsp;&nbsp; r456 --> associated with item 456


So when I run without condition1 and condition2 above is what I get.

That is jakal is associated with both r123 and r456.

However in my first query, I am trying to get the lnames and snames that are associated with keyword 123 but are not associated with item 456.

I want both conditions true to be displayed.

However when I write the query as mentioned initially, I get the row back.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2008
Added on Feb 14 2008
1 comment
315 views