as a beginner, I'm struggling with this for a few hours now, any help is much appreciated :D
I have 3 tables:
threads (id, title)
tags (id, name)
tag_thread (thread_id, tag_id)
The following, working code returns the 5 most used tags (names) of the latest 100 threads:
select ta.name
from tags ta
join tag_thread tt on tt.tag_id = ta.id
join (select * from threads order by id desc limit 100) th on tt.thread_id = th.id
group by ta.name
order by count(ta.name) desc
limit 5
Question: Given there is a $tagId, how would I have to change to query to filter the results so that only those tags show up, which are connected to threads that use tags with $tagId?
Thank you very much!