I have a cross reference table that looks like this:
id document_id subject_id
1 8 21
2 5 17
3 5 76
4 7
Using Oracle (or any database that allows the with clause). This allows definition of the subject_id values exactly once.
with t as (select distinct document_id from table1 where subject_id in (17,76) )
select document_id from table1 where subject_id in (select subject_id from t)
group by document_id
having count(*) = (select count (*) from t);