Subject | Re: Self join |
---|---|
Author | Adam |
Post date | 2006-02-05T11:30:50Z |
--- In firebird-support@yahoogroups.com, Damir Tesanovic <tdamir@...>
wrote:
work" error message others seem to get.
Perhaps it is not giving you the results you expect? (Hint: tell us
what results you are getting and what you expect)
Now I am guessing here, I would consider firstly, do you really want
left join? Based on your description,
"to get all barcodes from shop 1 and those from shop 2 even if there
is not pair"
I would have thought a full outer join would have been more
appropriate, or you will not see barcodes in shop 2 for which there is
no equivalent barcode in shop 1, unless this is what you want
12345, 12345
12346, <null>
34234, <null>
Adam
wrote:
>(A.barcode =
> Hi!
> I have a one table containing:
> shop_id, barcode, amount
> 1, 12345, 54
> 1, 12346, 34
> 1, 34234, 23
> 2, 12345, 32
> 2, 10000, 12
> 3, 43245, 2
>
> I tryed with
> SELECT A.barcode, B.barcode FROM shops A LEFT JOIN shops B ON
> B.barcode) WHERE A.shop_id = 1 AND B.shop_id = 2;if there
> command to get all barcodes from shop 1 and those from shop 2 even
> is not pair but it doesn't work.I dont know what I am doing wrong but I never get this "it doesn't
work" error message others seem to get.
Perhaps it is not giving you the results you expect? (Hint: tell us
what results you are getting and what you expect)
Now I am guessing here, I would consider firstly, do you really want
left join? Based on your description,
"to get all barcodes from shop 1 and those from shop 2 even if there
is not pair"
I would have thought a full outer join would have been more
appropriate, or you will not see barcodes in shop 2 for which there is
no equivalent barcode in shop 1, unless this is what you want
12345, 12345
12346, <null>
34234, <null>
Adam