MySQL Forums
Forum List  »  Newbie

Re: 3 tables joined with where clause
Posted by: Ibram N.
Date: September 04, 2020 04:18AM

So I need two queries? I found a solution with sub queries :

SELECT
c.id, c.title as title, CONCAT(GROUP_CONCAT(ta.tag)) as tags
FROM db_Content as c
LEFT JOIN db_ContentTag as ct ON ct.content_id = c.id
LEFT JOIN db_Tag as ta ON ta.id = ct.tag_id
WHERE
c.id IN (
SELECT ContentTag.content_id FROM ContentTag WHERE ContentTag.tag_id IN (
SELECT GROUP_CONCAT(Tag.id) FROM Tag WHERE Tag.tag LIKE '%agA%'
)
)
GROUP BY 1


it seems to work perpectly but it's a bit heavy. Do you have an idea to clean it ?

Options: ReplyQuote


Subject
Written By
Posted
September 03, 2020 08:39AM
September 03, 2020 10:49AM
Re: 3 tables joined with where clause
September 04, 2020 04:18AM
September 09, 2020 12:19AM


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.