I\'m trying to figure out how to order items with matching tags by the number of tags that match.
Let\'s say you have three MySQL tables:
tags(tag_id
Something resembling:
SELECT a.*
FROM articles AS a
INNER JOIN articles_tags AS at ON a.id=at.article_id
INNER JOIN tags AS t ON at.tag_id = t.id
WHERE t.title = 'funny' OR t.title = 'goofy' OR t.title = 'silly' AND a.id !=
GROUP BY a.id
ORDER BY COUNT(a.id) DESC
With just the usual indexes, assuming articles_tags has PK of (article_id, tag_id), and an index on tags.title