Re: Query Exclusion
Posted by:
fuzztrek
Date: July 03, 2005 06:54PM
Jay Pipes wrote:
> SELECT DISTINCT i.filename
> FROM icons i, keywords k1, keywords k2
> INNER JOIN rel_icon_keyword rik1
> ON i.icon_id = rik1.icon_id
> AND rik1.keyword_id = k1.keyword_id
> INNER JOIN rel_icon_keyword rik2
> ON i.icon_id = rik2.icon_id
> AND rik2.keyword_id = k2.keyword_id
> WHERE k1.keyword_name = 'X'
> AND k2.keyword_name = 'Y';
>
> Make sure you have an index on keywords
> (keyword_name) at least.
>
Ah, thank you very much! It never occured to me that I could call on one table twice in the same query.
Forgive my ignorance, but is there anyway to make this work so it will select icons related to one keyword but not the other? (e.g. X but not Y, or Y but not X) I tried
k2.keyword_name != 'Y';
which returned all icons related to X (even if they were also related to Y) and this:
k2.keyword_name NOT IN('Y', 'X');
which didn't return anything at all.
Thanks again!
Subject
Written By
Posted
Re: Query Exclusion
July 03, 2005 06:54PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.