Subject | Re: intersect operation |
---|---|
Author | vbj34 |
Post date | 2004-07-21T23:40:31Z |
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?
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
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?
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
> --- In firebird-support@yahoogroups.com, "vbj34" <vbj34@y...> wrote:Firebird
> > Hi, is it possible to perform set intersect operation with
> > SQL? Thanks.only
>
> Is this a difficult way to ask whether it is possible to return
> records that exists in two separate tables? If so, it is simply aso
> matter of doing
>
> SELECT <something>
> FROM <table1>
> JOIN <table2> ON <table2.field1> = <table1.field1>
>
> or (depending on what you want)
>
> SELECT <something>
> FROM <table1>
> WHERE EXISTS(SELECT * FROM <table2> WHERE <table2.field1> = <table1.
> field1>)
>
> If this is not what you are asking, please rephrase your question
> that it is easier for us to understand.
>
> HTH,
> Set