I have 3 tables.
news:
id
title
categories:
id
name
newsEachCategories:
postId
categoryId
Table newsEachCategories holds the id of each post and the id of the category in which it has been posted.
So if post with id 13 has been posted in categories 6 and 7, there are two entries, one "postId 13 , categoryId 6", and one "postId 13 , categoryId 7".
So in order to find all posts that are in a category (say category with id of 5) I use:
SELECT news.title , news.editedTitle , news.id
FROM news JOIN newsEachCategories
ON news.id = newsEachCategories.postId
WHERE newsEachCategories.categoryId = 5
How should I synxtax my query if I want to select posts that are both categories 5 and 6?