Subject Re: intersect operation
Author Svein Erling Tysvær
--- In, "vbj34" <vbj34@y...> wrote:
> I'm looking for a way to get records that exists in two separate
> lists (not necessarily tables). For example if I have 2 sql queries
> as such:
> (select Student
> from MajorsIn
> where Major='math')
> (select Student
> from MajorsIn
> where Major='CS')
> how to generate a list of the students majoring in both math and CS?

Use aliases:

select distinct M1.Student
from MajorsIn M1
join MajorsIn M2 on M1.Student = M2.Student
where M1.Major = 'math'
and M2.Major = 'CS'