Subject Re: [firebird-support] Union Issue
Author Helen Borrie
At 04:04 PM 21/10/2003 +0000, you wrote:
>This query works fine on by DB:
>
>select pensionPlan_ID from DB union
>select pensionPlan_ID from DC
>
>but this one does not:
>
>select * from PensionPlans where PensionPland_Id in
>(select pensionPlan_ID from DB union
>select pensionPlan_ID from DC)
>
>It does not like the word 'union'

Nope. Subqueries must return scalar output (one row, one column) and a
union is by nature 2 or more rows ---> so verboten.

>--is there a way to achive the same
>results (i.e. all items in PensionPlans that do not have an ID in the
>DB or DC tables)?

select * from PensionPlans pp
where (not (exists (select db.pensionPlan_ID from DB db
where pp.PensionPland_Id = db.pensionPlan_ID)))
and (not (exists (select dc.pensionPlan_ID from DC dc
where pp.PensionPland_Id = dc.pensionPlan_ID)))

heLen