tag
tag_id tag post_id
--------------------------------
1 category1 1
2 category2 1
3 etc 2
4 category3 1
post
post_id title
-------------
1 title1
How can we get title1 because its in the tag category1 && category2
something like
SELECT TITLE
FROM post, tag
WHERE tag.post_id = post.post_id
AND tags.tag = 'category1','category2'
In order to check if a title has BOTH ‘category1’ and ‘category2’, you can use the following SQL query:
To check for other categories you just repeat the WHERE clause:
This would return results for titles that have all 3 categories.