Q:

SQL Query to Find Matching Records but Excluding those that Match Second Criteria

I have a SQL database and I want to locate all the records that match one criteria, but exclude from that set of results the records that match a second criteria.  More specifically -
Table 'Documents' with Fields = 'DocID',    'Description',    'SignID'
Table 'Signatures' with Fields = 'SignID',    'SignatoryName'
I want to find all the Documents that have been signed by a specific Signatory e.g.
SELECT d.DocID, s.SignID
FROM Documents AS d
INNER JOIN Signatures AS s ON d.SignID = s.SignID
WHERE s.SignatoryName = 'Search Name Here';

However, many documents are signed by more than one person (i.e. Documents > Signatures is One-to-Many).  I want to exclude those documents which have been signed by anyone else, other than the specific Signatory in the above query.  Or put another way, I want to find all those Documents that have ONLY been signed by the specific Signatory.
But I'm not sure how to revise my query to achieve this objective.

A:

Give a try with below query:
(SELECT d.DocID, s.SignID
FROM Documents AS d)
temp1
INNER JOIN Signatures AS s ON d.SignID = s.SignID
WHERE s.SignatoryName = 'Search Name Here' and d.DOCID not in ( select DocID from temp1)

