Answer the question
In order to leave comments, you need to log in
Select posts by the most identical tags?
Post <-> Tag manyToMany. So there is a Pivot table in which post_id + tag_id lie.
In recommendations, display posts that have the most identical tags with the current one.
That's how I understand
SELECT *
FROM posts
INNER JOIN tags
WHERE posts.tags IN [1,5,8,12,56,4,44] // take posts which hase most alike tags
COUNT(posts.tags.id)
ORDER BY posts.tags.id
Answer the question
In order to leave comments, you need to log in
SELECT p.uuid, count(tg.tag_uuid) as TagCount
FROM episode_details p
INNER JOIN episodes_tags tg
ON p.uuid = tg.episode_uuid
INNER JOIN anime_tag t
ON tg.tag_uuid = t.uuid
WHERE t.uuid in (1, 54, 32)
GROUP BY p.uuid
ORDER BY TagCount DESC
limit 3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question