Skip to content
Advertisement

comparing two tables and removing ones that match

I have two tables. MembID is the only column returned for each. The MembID can be in both tables but I would like to remove the ones that are in both from the results.

enter image description here

I’d like the final return to be 456 and 789 from Table A.

I’ve tried:

select distinct a.membid
from a
 left join b on a.membid = b.membid
and b.num <> 1 

it does not return any results.

Thanks.

Advertisement

Answer

try like below

select distinct a.membid
from a
 left join b on a.membid = b.membid
where b.membid is null
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement