MySQL Forums
Forum List  »  Newbie

Re: Query Exclusion
Posted by: Jay Pipes
Date: July 03, 2005 11:05AM

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.

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Written By
Posted
July 03, 2005 09:18AM
July 03, 2005 09:26AM
Re: Query Exclusion
July 03, 2005 11:05AM
July 03, 2005 06:54PM
July 04, 2005 11:54AM
July 04, 2005 02:18PM


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.