Re: tricky query question
Date: 9 Nov 94 10:37:48 +1000
Message-ID: <1994Nov9.103748.1_at_cnb07v.hhcs.gov.au>
In article <khuisman.32.000E846A_at_wnet.gov.edmonton.ab.ca>, khuisman_at_wnet.gov.edmonton.ab.ca (Ken Huisman) writes:
> I have a table with a 1:M relationship to another table.
>
> I would like to do a query on the first table based on whether or not there
> exists related rows in the second table. The closest i have come is to just
> do a join and retrieve the data on the 1 side several times - but i dont want
> this because i only want to retrieve each row once.
>
> i would like something like this:
>
> select id from table1 where id is a member of ( select table1id from table2
> where blah blah blah...)
>
There are at least 2 ways of doing this
- select id from table1
where id in (select table1id from table2)
- select distinct table1.id from table1,table2 where table1.id = table2.id
> kind of a set membership kind of thing.
>
> Is there a way to do this?
>
> many thanks.
>
>
> Ken
> khuisman_at_wnet.gov.edmonton.ab.ca
>
-- -------------------------------------------------------------------------------- Steven Champness champs_at_cnb07v.hhcs.gov.au Dept of Human Services & Health Brisbane, Queensland, Australia The opinions expressed above were found in a box of breakfast cerealReceived on Wed Nov 09 1994 - 01:37:48 CET