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
That's a very interesting question.
I'm assuming you would like a more generalized query, but this is what I would do in the case where you always have the same number of subjects (say two):
SELECT T.id, T.document_id, T.subject_id
FROM table T
INNER JOIN table T1 ON T.document_id = T1.document_id AND T1.subject_ID = 17
INNER JOIN table T2 ON T.document_id = T2.document_id AND T2.subject_ID = 76
Of course, you could add yet another INNER JOIN to add another subject ID.. But I admit it's not a very good general solution.