View Full Version : Exclusions


Skinn102
04-04-2007, 11:54 PM
Hi

Pretty new to all this, so please bear with me while i try and explain.

I have a table called exclusions with three columns: Domain, Process, and Sub Process.

What I want to do is run a query from another table, excluding anything that matches all three columns in the exclusions table. :confused:

I've started off with something like this.

SELECT *
FROM Dashboard_Closed, Excluded
WHERE (((Excluded.Domain) Is Null) And ((Excluded.Process) Is Null) And ((Excluded.[Sub Process]) Is Null));

But I don't seem to be getting anywhere, i just get a blank Query. I'm very very much a beginner to all this, so if anyone can help I would be eternally grateful.

Thanks

tehNellie
04-05-2007, 12:19 AM
you need a Left join on the fields in question.
So to get all the data from Dashboard_close where those three columns don't match Excluded you'd use


SELECT *
FROM Dashboard_closed
LEFT JOIN Excluded ON
Dashboard_closed.[domain] = Excluded.[domain]
AND
Dashboard_closed.[process] = Excluded.[process]
AND
Dashboard_closed.[sub process] = Excluded.[sub process]
WHERE (excluded.[domain] is null) AND (excluded.[process] is null) AND (excluded.[subprocess] is null)


I'm sure Access will stick a million more random brackets around my WHERE clause when it's cut and pasted

The left join gets you everything from the left side of the join, Dashboard_closed in this case, regardless of whether there is match in the corresponding table so we can now filter by NULL to find the un-matched records.

In the query builder options you can have access write you an unmatched query, but I believe that it will only work on one field.