 <p>Try this. I am sure you can do this via a couple JOINs (or at least part of it) but you did not request what your return columns should be</p> <pre><code>SELECT v.visitID FROM Visits AS v WHERE EXISTS(SELECT * FROM VisitDocs AS d WHERE d.VisitID = v.VisitID AND d.docType = 3) AND NOT EXISTS(SELECT * FROM VisitDocs AS d WHERE d.VisitID = v.VisitID AND d.docType Not IN (1,2)) </code></pre>