Retrn result only if both conditions are true
450482Feb 14 2008 — edited Feb 15 2008I 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 sname rname
jakal jkl r123 --> associated with keyword 123
jakal jkl 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.