Access SQL NOT IN multiple criteria

MCTampa

Board Regular
Joined
Apr 14, 2016
Messages
97
I have a small query which works in the following setup.

SQL:
SELECT
O.[Check In Year],
O.Cost,
O.UCDX,
O.[Area#],
O.RESX,
O.[Check-In],
O.Units,
O.[All Inclusive],
O.CMGX

From Output O left Join DVW D On
O.RESX = D.RESX

Where O.RESX NOT IN
(
Select RESX
From DVW
)

This identifies RESX which are not on the table DVW.

But I need the criteria to be more detailed

On my left join, I need to add:
O.UCDX = D.Size
AND O.[Check-In] = DVW.EXDTFDTF

But I can't seem to get it to work properly in the NOT IN portion of the query.

I was trying to build it out like this:

SQL:
SELECT
O.[Check In Year],
O.Cost,
O.UCDX,
O.[Area#],
O.RESX,
O.[Check-In],
O.Units,
O.[All Inclusive],
O.CMGX

From Output O left Join DVW D On
O.RESX = D.RESX
AND O.UCDX = D.SIZE

Where O.RESX NOT IN
(
Select RESX
From DVW
)
AND
Where O.UCDX NOT IN
(
Select UCDX
From DVW
);
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Make a union query out of the 2 Selects that make up the two Not In and use that query name in to Not Select from?
 
Upvote 0
Bit late to the party! But isn't this what you want:

SQL:
SELECT
    O.[Check In Year],
    O.Cost,
    O.UCDX,
    O.[Area#],
    O.RESX,
    O.[Check-In],
    O.Units,
    O.[All Inclusive],
    O.CMGX
From 
    Output O 
        left Join DVW D 
            On O.RESX = D.RESX
            and O.UCDX = D.Size
            AND O.[Check-In] = D.EXDTFDTF
Where 
    D.RESX is null
 
Upvote 0

Forum statistics

Threads
1,215,165
Messages
6,123,390
Members
449,098
Latest member
ArturS75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top