I have this tables: Posts (post_is, title and text), Tags (tag_id, tag), Post_tag_nn (id, tag_id, post_id). I want for a specific post having for example 4 tags all the posts with those tags, then all the posts with any three of those tags, then all posts with any two of those tags and so on. How can i build a SQL query for this purpose (in php it seems like a backtracking problem=all the subsets of a given set).
I have this tables: Posts (post_is, title and text), Tags (tag_id, tag), Post_tag_nn (id,
Share
Have a query to find the tags of the current post, something like
Then using those tag id’s, this query should return you the id’s of posts with 4,3,2,… matching tags: