Exclusion Query Question

G

Guest

Have 2 tables, tblA, tblB. I need a query that selects all the records in
tblA that meet a set of criteria EXCEPT if there is a matching record in
tblB.

Query of tblA gives:
EntryID PenaltyID Penalty
354 7 0
638 8 0
111 5 0

Query of tblB gives:
EntryID PenaltyID Penalty
638 8 4.2

The result I need is:
EntryID PenaltyID Penalty
354 7 0
111 5 0

the record for EntryID 638 in NOT to be shown since we are looking for
entries with no penalties.

Any and all help is appreciated
 
G

Guest

I think this is what you want:

SELECT tblA.EntryID, tblA.PenaltyID, tblB.Penalty FROM tblA LEFT JOIN tblB
ON tblA.EntryID = tblB.EntryID AND tblA.PenaltyID = tblB.PenaltyID WHERE
tblB.Penalty IS NULL;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top