From: | Tim Landscheidt <tim(at)tim-landscheidt(dot)de> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: UNION or LEFT JOIN? |
Date: | 2010-02-16 21:38:19 |
Message-ID: | m3635wuaic.fsf@passepartout.tim-landscheidt.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org> wrote:
> Here is the basic schema:
> -------------------------->id_ship>-----------------------
> | |
> [SHIP]->id_ship->[CABIN]->id_cabin->[PRICE]<-id_cruise<-[CRUISE]
> It's a database of cruise prices.
> Each 'price' object has a reference to 'cabin' and 'cruise'
> 'cabin' belongs to a 'ship', so does 'cruise'
> I'm trying to select all cabins of cruise N°1 with prices OR nothing if
> there is no price (meaning cabin not available). I want all cabins
> listed, price or no price.
> Also when doing the query I don't have the id_ship, only the id_cruise.
> What is the best way of doing it? UNION or LEFT JOIN? I tried the latter
> without success and am unsure on how do do the former.
Was does "without success" mean? The objective seems to be
straight-forward:
- Select all cabins that belong to the ship that belongs to
the cruise id_cruise.
- Left join that with the prices of the cruise id_cruise.
Tim
From | Date | Subject | |
---|---|---|---|
Next Message | Louis-David Mitterrand | 2010-02-16 21:43:05 | Re: UNION or LEFT JOIN? |
Previous Message | Louis-David Mitterrand | 2010-02-16 21:02:23 | Re: UNION or LEFT JOIN? |