Subject | Re: Select distinct record from the Master table through a join |
---|---|
Author | dianeb77x |
Post date | 2001-12-05T14:24:42Z |
--- In ib-support@y..., "Junior Ang" <junior@c...> wrote:
records, is this the best and only way?
select A.ID from TABLE1 A where exists (select * from TABLE2 B where
B.ID = A.ID and B.QTY > 100)
Doesn't use a join (therefore eliminating need to use 'distinct',
assuming A.ID is unique in TABLE1), just checks for presence or
absence of detail records matching your criteria.
Not sure if it's better or worse, just different.
Cheers,
db
> Hi,Likewise!
>
> Greetings.
>duplicate, when the criteria are to be based on the detail table
> If I want to retrieve records from the master table which should not
records, is this the best and only way?
>B.ID where B.QTY > 100
> select distinct A.ID from TABLE1 A inner join TABLE2 B on A.ID =
>You could also try something like this:
> where TABLE1 is the master table and TABLE2 is the detail table.
>
select A.ID from TABLE1 A where exists (select * from TABLE2 B where
B.ID = A.ID and B.QTY > 100)
Doesn't use a join (therefore eliminating need to use 'distinct',
assuming A.ID is unique in TABLE1), just checks for presence or
absence of detail records matching your criteria.
Not sure if it's better or worse, just different.
Cheers,
db