Query is not working

raj08536

Active Member
Joined
Aug 16, 2007
Messages
250
I have two tables. One is 2nd Level AFDA and other InterCompany

2nd Level AFDA has 5 fields and Intercompany has two.

Both have SAPStrNo field comman. I want to join thes tables and ignore all the SAPStrNo records found in InterCompany. Following SQL query is not working.
I have 1206 records in 2nd Level AFDA and 22 records in Intercompany. Following Query generate 26531 records which definetly wrong because I expect less than 1206 records due to this query


SELECT [2nd Level AFDA].SAPStrNo, [2nd Level AFDA].StoreNo, [2nd Level AFDA].AccType, [2nd Level AFDA].Sortype, [2nd Level AFDA].Banner
FROM [2nd Level AFDA] where [2nd Level AFDA].SAPStrNo <> InterCompany.SAPStrNo;
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
Hi

So you want all records in 2nd Level AFDA that has no match in Intercompany?

Code:
SELECT T1.SAPStrNo, T1.StoreNo, T1.AccType, T1.Sortype, T1.Banner
FROM [2nd Level AFDA] T1 LEFT JOIN Intercompany T2 On T1.SAPStrNo = T2.SAPStrNo WHERE T2.SAPStrNo Is Null;
 

Watch MrExcel Video

Forum statistics

Threads
1,122,517
Messages
5,596,620
Members
414,081
Latest member
Subaru_Steve

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
Top