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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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