I have 2 tables. I want to get all students id from table A who never went to college. So result should only return "2" here.
Table A
Student ID
1
2
3
Table B
1 - School
1 - College
2 - School
3 - School
3 - College
I have 2 tables. I want to get all students id from table A who never went to college. So result should only return "2" here.
Table A
Student ID
1
2
3
Table B
1 - School
1 - College
2 - School
3 - School
3 - College
one way is to use not exists which is the fastest if you are working with huge data:
select *
from TableA
where not exists ( select 1 from table2 
                   where table1.studentid = tableb.studentid 
                   and schoolcol = 'college'
                 )
