This works. Doubt it is efficient though. Any way to simplify it?
FROM tags, topic, tagConnect
WHERE tagConnect_article = topic_id
AND tagConnect_tag = tag_id
IN ( 3, 4 )
HAVING COUNT( * ) =2
GROUP BY tag
wow... Im really bad when I cant draw something. Sorry.
Say I have 9 buttons - each one representing a tag.
When I press one, I am given a list of all the articles that are tagged with that tag.
When I press a second one, the first one is still selected. So now I want a result of articles that are tagged with both. (you already figured this out)
What I want to know, is before I press another button down, will there any results. This way I am not wasting time looking for combinations that work.
To do this, I need to know, what tags have not been selected, but who are also attributed to at least one of the articles in that returned list.
So if I select button 1,2 and are given 20 results. But none of those 20 results are also tagged with 9, I dont want to press it.
I figure it would be something like:
if I select button 1,2 and are given 20 results.
Return a list of tags that can be used in combination with 1,2 and still return results.
So maybe come back as 4,6 (not 3 or 5)because
10 articles are tagged 1,2,4
5 are tagged 1,2,6
1 is tagged 1,2,4,6
I dont need to know how many articles would come back. Just what tags could be added to the current selection and still return at least 1 result.