Subject | Re: [ib-support] Self left join |
---|---|
Author | Arno Brinkman |
Post date | 2003-04-10T21:49:21Z |
Hi,
p1.name, p2.name
from
products p1
left join products p2 on (p2.name = p1.name and p2.account_id = 2)
where
p1.account_id = 1
Regards,
Arno Brinkman
> I would like a list of all products from account_id = 1, and thosematching
> products from account_id = 2. The following query only returns matchingselect
> products, not the complete list of products from the first account_id:
>
> select
> p1.name, p2.name
> from
> products p1
> left join products p2 on (p2.name = p1.name)
> where
> p1.account_id = 1 and
> p2.account_id = 2
> Is this not possible? I know that if there was a Product1 and a Product2
> table, the left join would work correctly.
p1.name, p2.name
from
products p1
left join products p2 on (p2.name = p1.name and p2.account_id = 2)
where
p1.account_id = 1
Regards,
Arno Brinkman