Subject | Re: [firebird-support] Self join |
---|---|
Author | Ann W. Harrison |
Post date | 2006-02-05T18:01:44Z |
Ann W. Harrison wrote:
be
SELECT A.barcode, B.barcode
FROM shops A LEFT JOIN shops B
ON (A.barcode = > B.barcode
AND B.shop_id = 2)
WHERE A.shop_id = 1;
If you think the ON clause is ugly, you could write the
query like this:
SELECT A.barcode, B.barcode
FROM shops A LEFT JOIN shops B
ON (A.barcode = > B.barcode)
WHERE A.shop_id = 1 AND
(B.shop_id = 2 or B.shop_id IS NULL);
I doubt there would be any performance difference.
Regards,
Ann
>There's an editing mouse turd there - should
> SELECT A.barcode, B.barcode
> FROM shops A LEFT JOIN shops B
> ON (A.barcode = > B.barcode A
> AND B.shop_id = 2)
> WHERE A.shop_id = 1;
>
be
SELECT A.barcode, B.barcode
FROM shops A LEFT JOIN shops B
ON (A.barcode = > B.barcode
AND B.shop_id = 2)
WHERE A.shop_id = 1;
If you think the ON clause is ugly, you could write the
query like this:
SELECT A.barcode, B.barcode
FROM shops A LEFT JOIN shops B
ON (A.barcode = > B.barcode)
WHERE A.shop_id = 1 AND
(B.shop_id = 2 or B.shop_id IS NULL);
I doubt there would be any performance difference.
Regards,
Ann