Any quick way to get the "complement" of a query?

dcx693

Registered User.
Local time
Today, 16:28
Joined
Apr 30, 2003
Messages
3,265
Let me explain....

I have a query that looks something like this:
SELECT * FROM tbl1 INNER JOIN tbl2 ON (tbl1.Field1=tbl2.Field1) AND (tbl1.Field2=tbl2.Field2) AND (tbl1.Field3=tbl2.Field3)

Now what I want are the records that are not selected, basically what I would get from:
SELECT * FROM tbl1 - the results from the above query.

What's the easiest way to do this? I guess I could run the "full" query and run a delete query, but was wondering if there was a quicker way.
 
Change the join type to Left and add selection criteria:

SELECT * FROM tbl1 LEFT JOIN tbl2 ON (tbl1.Field1=tbl2.Field1) AND (tbl1.Field2=tbl2.Field2) AND (tbl1.Field3=tbl2.Field3)
Where tbl2.Field1 Is Null;
 
Pat, works beautifully. Thank you!
 

Users who are viewing this thread

Back
Top Bottom