I have four tables (but I'll query only three of them):
Articles (article is an 'item', type 6): *a_id, a_title, a_text*
Keywords (if a keyword is for articles, its type is 6): *kw_id, kw_type*
Keywords_Translation *kw_id, language_id, kw_name*
Conn_Item_Keyword (many-to-many connection table between items and keywords): *kw_id, kw_type, item_id*
Let's say that I want to query all the keywords of an article with ID 15 and in English (language_id = 1).
I could write this:
SELECT * FROM Conn_Item_Keyword c
LEFT JOIN Keywords k ON (c.kw_id = k.kw_id)
LEFT JOIN Keywords_Translation tr ON (c.kw_id = tr.kw_id)
WHERE c.kw_type = 6 AND c.item_id = 15 AND tr.language_id = 1
But it seems to me very slow, since it joins the Keywords to all the rows of Conn_Item_Keyword. I tried multiple conditions in joins (c.kw_id = k.kw_id AND c.kw_type = 6 AND c.item_id = 15), but I couldn't figure it out correctly.
What's the best way to write this query?