Reputation: 704
I have two tables, A and B.
A
ID age
1 24
2 25
45 22
B
ID school
34 school1
1 school2
I want to select IDs that are in B but not in A. I wrote
Select distinct bb.school
From B as bb
Left outer join A as aa
On bb.ID=aa.ID
inner join C as cc
On bb.school=cc.school
This code returns exactly the same number of rows that I would have with an inner join instead of left outer join. Am I doing something wrong?
Upvotes: 0
Views: 90
Reputation: 1115
Try using not in
;
Select * From A Where ID Not In ( Select ID From B )
Upvotes: 1