MySQL Forums
Forum List  »  Newbie

Re: JOIN from 3 tables - not possible to do it with subquerys
Posted by: Felix Geerinckx
Date: February 02, 2007 01:56AM

Tobias Kazmierczak Wrote:

> it there a way for a query in mysql 4 or do i have
> to update also the server

Does
SELECT 
    i.id,
    SUM(ik.relevance) AS SR
FROM images i
JOIN imgkey ik ON ik.id_img = i.id
JOIN keywords k ON k.id = ik.id_key
WHERE 
    k.keyword_en IN  ("Jesus", "Mary")
GROUP BY i.id
HAVING COUNT(i.id) = 2   -- 2 = number of elements in IN-list
ORDER BY SR DESC;
work?

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
Re: JOIN from 3 tables - not possible to do it with subquerys
February 02, 2007 01:56AM


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.