Reputation: 704
I have two tables
A
ID age
1 24
2 25
45 22
B
Name school Surname
34 school1 141
1 school2 152
I want to select Surname from B only for those Names that are not in A. ID and name have the same meaning in the two tables, but different name. I wrote
Select distinct bb.Surname
From B as bb
Left outer join A as aa
On bb.Name=aa.ID
But the number of rows is the same as an inner join between the two tables. I have approximately 100000 rows, so I cannot check manually. Do you spot failures in my approach?
The answer provided is not solving the issue as I am getting the same values as an inner join, so something is clearly wrong.
Upvotes: 0
Views: 33
Reputation: 5225
select b.surname
from tableb as b
left join tablea as a on b.name=a.id
where a.id is null
Upvotes: 2