I have a two tables one for documents one for mapping to categories.
Documents
id | document_name
1 | somename.doc
2 | anothername.doc
Documents_to_categories
cat_id | doc_id
10 | 1
10 | 2
11 | 3
12 | 1
Some documents can map to multiple categories. What I want is to be able to select documents that belong in multiple categories, like in a filtering scheme.
Basically in the script I have an array of document id's that were a result from a search. I need to filter those documents down based on categories.
This is what something like what I'm aiming for (I know it doesn't work but for example).
SELECT *
FROM Documents_to_categories A
JOIN Documents B ON A.doc_id = B.id
WHERE B.id IN (6703,6614,2286)
AND A.cat_id = :ID0
AND A.cat_id = :ID1
Edit: Sorry for all those who answered, my first time posting, was unclear with question. Hopefully this is more clear on what I want.