I asked this question before and got a great working answer.
what is the query to get "related tags" like in stack overflow
but i realized that SOF ac
Let's say you have a table called entity_tags
linking entities
with the tags
like this :
entity_id : INTEGER
tag_id : INTEGER
Let's say you user as selected N tags @1, @2, ... @N. To get the other tags associated with the results (and as a bonus, their frequency of occurence):
SELECT et.tag_id, COUNT(et.entity_id) as frequency FROM
entity_tags AS et
JOIN entity_tags AS et1 ON (et1.entity_id=et.entity_id AND et1.tag_id=@1)
...
JOIN entity_tags AS etN ON (etN.entity_id=et.entity_id AND etN.tag_id=@N)
WHERE et.tag_id NOT IN (@1, @2, ... @N)
GROUP BY et.tag_id;