Subject RE: [ib-support] left outer join in interbase
Author Dmitry Yemanov
Hi Herman,

> but further question, if the PRODUCT table has STATUS field,
> and we want the list of all product only with STATUS = 1,
> how to make the query ?
>
> I mean something like this :
>
> PRODUCT :
> P1 - Product1 - 1
> P2 - Product2 - 1
> P3 - Product3 - 1
> P4 - Product4 - 0
> P5 - Product5 - 0
>
> PODETAIL
> 1 - P1 - 10
> 1 - P2 - 10
>
> the result should be
>
> 1 - P1 - Product1 - 10
> 1 - P2 - Product2 - 10
> 1 - P3 - Product3 - <null>
>
> so we filter the list of product again...., it show not all
> products but
> certain products that meet criteria (STATUS = 1).
>
> how to make query like that ?

Just limit the result set with explicit WHERE clause:

select <:your_param>, ID, NAME, QTY
from PRODUCT left join PODETAIL
on PRODUCT_ID = ID and PO_ID = <:your_param>
where STATUS = <:your_another_param>;

I think it should meet your requirement.

Cheers,
Dmitry